Skip to content

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

Notifications You must be signed in to change notification settings

guicho271828/immutable-struct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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
(<name> &optional <slots…>). No keyword argument.

macro 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))

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 (guicho2.71828@gmail.com)

License

Licensed under the LLGPL License.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published