Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/guicho271828/immutable-struct

Simple library that encourage the use of functional programming + pattern matching.
https://github.com/guicho271828/immutable-struct

Last synced: 29 days ago
JSON representation

Simple library that encourage the use of functional programming + pattern matching.

Awesome Lists containing this project

README

        

* IMMUTABLE-STRUCT

Simple library that encourage the use of functional programming +
pattern matching.

+ =defstruct= --- provides truely nondestructive structure + integrates
well to the pattern matchers (either optima or trivia).
+ =ftype= --- shorthand expression of =declaim ftype=

** macro defstruct (name-and-options &rest slots)

A variation of defstruct, with read-only slots and automatically defined constructor.

+ Read-only, Noninterned Slot Name :: Standard =:read-only= feature in cl
does not prohibit the use of slot-value.
+ Constructor Function with the Same Syntax as that of Pattern Matcher :: (
&optional ). No keyword argument.

** macro ftype (name-or-names &rest types)

Abbreviation of =(declaim (ftype (function () ) ))=.
In a smart implementation like sbcl, using =ftype= declaration is preferred
over =the= and =(declare (type ...))=.

Besides, =defun= and =ftype= both have 5 characters and gives cleaner code.

: (ftype my+ fixnum fixnum fixnum)
: (defun my+ (a b) (+ a b))

** Dependencies

This library is at least tested on implementation listed below:

+ SBCL 1.2.8 on X86-64 Linux 3.13.0-45-generic (author's environment)

Also, it depends on the following libraries:

+ Trivia by me ::

+ alexandria ::
Alexandria is a collection of portable public domain utilities.

* Copyright

Copyright (c) 2015 Masataro Asai ([email protected])

* License

Licensed under the LLGPL License.