immutable-struct

2015-07-10

Library that encourage the use of functional programming + pattern matching

Upstream URL

github.com/guicho271828/immutable-struct

Author

Masataro Asai

License

LLGPL
README

1IMMUTABLE-STRUCT

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

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

1.1macro 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 cldoes not prohibit the use of slot-value.
Constructor Function with the Same Syntax as that of Pattern Matcher
(<name>&optional <slots...>). No keyword argument.

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

Abbreviation of (declaim (ftype (function (<types...>) <type>) <name-or-names...>)). 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))

1.3Dependencies

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.

2Copyright

Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com)

3License

Licensed under the LLGPL License.

Dependencies (3)

  • alexandria
  • closer-mop
  • trivia

Dependents (2)

  • GitHub
  • Quicklisp