UNSUPPORTED. UNSTABLE. INCOMPLETE. A Common Lisp library providing an enhanced (insane?) version of DESTRUCTURING-BIND. DESTRUCTURING-BIND* is 95% backwards-compatible with DESTRUCTURING-BIND (fixing a few "bugs") and additionally provides nil-as-ignore, &doc, &decl, &transform, &entire, &head, &tail, &copy, &share and &setf.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README
UNLICENSE
destructuring-bind-star.asd
examples.lisp
main.lisp
package.lisp
util.lisp

README

Project's home: http://www.hexstreamsoft.com/projects/destructuring-bind-star/


UNSUPPORTED. UNSTABLE. INCOMPLETE. destructuring-bind-star is a Common
Lisp library providing an enhanced (insane?) version of
DESTRUCTURING-BIND. DESTRUCTURING-BIND* is 95% backwards-compatible
with DESTRUCTURING-BIND (fixing a few "bugs") and additionally
provides nil-as-ignore, &doc, &decl, &transform, &entire, &head,
&tail, &copy, &share and &setf.

Here's an overview of the enhanced features, explained in detail in
the comprehensive documentation:

- nil-as-ignore: It's easy to unconditionally match and ignore a part
  of the pattern by providing NIL where a variable name is allowed.

- Support for extraction of docstrings and declarations
  with the &doc and &decl lambda keywords.

- Support for (functional) transformations, which allows one to do
  some "normalization" of the rest of the pattern prior to further
  processing, with &transform. This notably helps with the recurrent
  pattern of having a symbol be equivalent to a list with that symbol,
  as seen in LET bindings, various parts of destructuring bindings,
  class slots, and many other places.

- &entire can be used after a transform (or many transforms) to
  capture what &whole at the start of that recursive pattern would
  have captured, except that any transforms before that &entire lambda
  keyword are visible. This lets you use destructuring patterns "for
  normalization", especially when used with nil-as-ignore.

  &doc and &decl can also count as a transformation (or rather,
  normalization) that &entire can capture: the docstring and
  declarations will be appear in the same order as &doc and &decl were
  specified, no matter how they appeared in the matched expression.

- &tail is much like &rest except it can be inserted almost anywhere
  (and at multiple places) in the pattern, capturing the rest of the
  matched value. &tail doesn't affect the semantics of the pattern,
  for instance &tail in a pattern that accepts exactly 3 arguments
  still accepts exactly 3 arguments.

  &tail can also be used in the middle of &key parameters. In this
  case, the captured value is the one that &rest would have captured
  before &key, but with any keyword parameters before the &tail
  keyword removed.

- &head is the "complement" of &tail, it captures a copy of all the
  matched pattern up to that point.

- Support for flexible copying and sharing with &copy and &share.

- Support for easy destructive modification with &setf. &setf is used
  with a variable in the pattern. Within the body of
  DESTRUCTURING-BIND*, the variable is a SETFable place that can
  update the original matched expression or a copy of it, depending on
  if &setf is in the scope of &share (the default) or &copy. If there
  are variables "downstream" in the pattern, they are automatically
  updated to reflect the modification.

Additionally, the following "bugs" have been fixed:

- It's possible to use a variable name at the "top-level" of the
  pattern, matching any value. The original DESTRUCTURING-BIND has the
  fairly arbitrary restriction (IMHO) that it can only operate on a
  list.

- Patterns equivalent to (&rest rest) can match any object, not just a
  list. This nicely mirrors the way (a &rest rest) can match a cons
  with any value whatsoever in the CDR.


This library is in the Public Domain.
See the UNLICENSE file for details.