The positional-lambda Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The positional-lambda Reference Manual

This is the positional-lambda Reference Manual, version 2.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:25:58 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Project's home: http://www.hexstreamsoft.com/projects/positional-lambda/


(This documentation is pretty bare, I'll update it when I'm done
making a great documentation system. I didn't yet take care of the
"paucity of examples" and "absence of formal description" problems.)


positional-lambda is a concise, intuitive and flexible syntax (macro)
for trivial lambdas that eschews explicit (and often
contextually-redundant) naming of parameter variables in favor of
positional references, with support for a used or ignored &rest
parameter and automatic declaration of ignored parameters when logical
"gaps" are left in the positional references. Further convenience
features are provided.

(plambda (values :3 :1))
==
(lambda (first second third)
  (declare (ignore second))
  (values third first))

(plambda (list* :2 :1 :rest))
==
(lambda (first second &rest rest)
  (list* second first rest))

(plambda :rest (list :2 :1))
==
(lambda (first second &rest rest)
  (declare (ignore rest))
  (list second first))


It's possible to specify a minimum number of required arguments:

(plambda :3 :2)
==
(lambda (first second third)
  (declare (ignore first third))
  second)

(plambda :2 :3) ; redundant minimum: 3 > 2.
==
(plambda :3)


Which also has the effect of "pushing back" the &rest argument if there's one:

(plambda :3 (mapcar :1 :rest))
==
(lambda (first second third &rest rest)
  (declare (ignore second third))
  (mapcar first rest))


The first argument to PLAMBDA is treated as a specification of the
minimum number of arguments only if it looks like a positional reference
and PLAMBDA was invoked with other arguments:

(plambda :2)
==
(lambda (first second)
  (declare (ignore first))
  second)


PLAMBDA accepts an implicit PROGN, not just one expression:

(plambda (print :1) :2)
==
(lambda (first second)
  (print first)
  second)


Also, PLAMBDA's :let "local special operator" allows one to "lift" parts of
its body outside the lambda to a LET without needing to name and then
refer to an explicit variable.

(plambda :2 (list :1 (:let (random))))
==
(let ((number (random)))
  (lambda (first second)
    (declare (ignore second))
    (list first number)))


Another feature is :cache, which is like :let except it computes the
associated form in its original lexical and dynamic context within the
lambda the first time its evaluation completes and returns the cached
value on subsequent evaluations.

(plambda (write :1 :base (:cache *print-base*)))
==
(let (base basep)
  (lambda (first)
    (write first :base (if basep
                           base
                           (prog1 (setf base *print-base*)
                             (setf basep t))))))

The consequences are undefined if the :let and :once local special
operators are nested within themselves or eachother:

(plambda (:let (:let 1))) ; undefined


PLAMBDA will treat any quoted expressions as opaque, and will treat
anything wrapped in the :quote local-special-form as opaque as well.

(plambda ':1)
==
(lambda () ':1)

(plambda () (:quote :1))
==
(lambda () :1)


Unfortunately, currently PLAMBDA won't do the right thing with some
expressions that are quoted via backquote (since there's no easy
portable way to walk backquoted expressions).

(plambda `(:1 ,:2))
==
[:1 will be erroneously replaced]


To use lambda-lift, simply (:import-from #:lambda-lift #:lift) from
your DEFPACKAGE. Don't (:use #:lambda-lift)! "Clashy" symbols might be
added to the lambda-lift package in the future.


positional-lambda should only be used to describe actually trivial
lambdas, usually no more than 3 lines long, and should not be used in
code returned by macros, because of "capture" issues. In particular,
due to the PLAMBDA macro's parsing model, it's not safe to nest multiple
invocations.

However, these are not practical limitations since as PLAMBDA's
expressions get bigger, the benefits of conciseness quickly fade out
to be replaced by the problems of implicitness, so hopefully one
wouldn't be tempted to use it in these scenarios anyway. The
implicitness is not a problem for suitably short PLAMBDA expressions
since the surrounding context provides enough contextual information,
and explicitly naming variables would then simply provide redundant
information.

PLAMBDA's deliberately simplistic "surface parsing" (and replacement)
strategy is conceptually and implementationally simple and robust, as
opposed to often-brittle "code-walking" where an attempt is made to
take into account the actual semantics of forms and operators, often
necessitating explicit support when new operators are introduced.


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


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 positional-lambda

Author

Jean-Philippe Paradis <hexstream@gmail.com>

License

Public Domain

Description

positional-lambda is a concise, intuitive and flexible syntax (macro) for trivial lambdas that eschews explicit (and often contextually-redundant) naming of parameter variables in favor of positional references, with support for a used or ignored &rest parameter and automatic declaration of ignored parameters when logical "gaps" are left in the positional references. Further convenience features are provided.

Version

2.0

Dependency

map-bind

Source

positional-lambda.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 positional-lambda.asd

Location

positional-lambda.asd

Systems

positional-lambda (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 positional-lambda/package.lisp

Parent

positional-lambda (system)

Location

package.lisp

Packages

positional-lambda


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 positional-lambda/main.lisp

Dependency

package.lisp (file)

Parent

positional-lambda (system)

Location

main.lisp

Exported Definitions

plambda (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 positional-lambda

Source

package.lisp (file)

Nickname

plambda

Use List

common-lisp

Exported Definitions

plambda (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: plambda &body BODY
Package

positional-lambda

Source

main.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Macros

Macro: multiple-value-&bind LAMBDA-LIST VALUES-FORM &body BODY
Package

positional-lambda

Source

main.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: %assemble BODY &key LET-BINDINGS LAMBDA-LIST IGNORED-VARS &allow-other-keys
Package

positional-lambda

Source

main.lisp (file)

Function: %compute-lambda-list USED-REQUIRED-VARS MIN-LENGTH REST-USAGE REST-VAR
Package

positional-lambda

Source

main.lisp (file)

Function: %gensym-generator &optional DEFAULT-BASE
Package

positional-lambda

Source

main.lisp (file)

Function: %make-bindings-accumulator ()
Package

positional-lambda

Source

main.lisp (file)

Function: %make-lambda-list-accumulator ()
Package

positional-lambda

Source

main.lisp (file)

Function: %make-positional-gaps-filler CALLBACK &key START MIN-END
Package

positional-lambda

Source

main.lisp (file)

Function: %make-positional-vars-accumulator VAR-FUNCTION
Package

positional-lambda

Source

main.lisp (file)

Function: %make-walking-state-closures &key MIN-LENGTH-INDICATOR ACCEPT-REST-P &allow-other-keys
Package

positional-lambda

Source

main.lisp (file)

Function: %parse-body BODY
Package

positional-lambda

Source

main.lisp (file)

Function: %positional-ref-p OBJECT
Package

positional-lambda

Source

main.lisp (file)

Function: %processing-local-special-forms LOCAL-SPECIAL-FORMS-ALIST ELSE
Package

positional-lambda

Source

main.lisp (file)

Function: %standard-expansion-process PARSE-BODY MAKE-WALKING-STATE MAKE-LOCAL-SPECIAL-FORMS ASSEMBLE
Package

positional-lambda

Source

main.lisp (file)

Function: %standard-local-special-forms &key ADD-LET-BINDING &allow-other-keys
Package

positional-lambda

Source

main.lisp (file)

Function: %walk BODY PROCESS-POSSIBLE-TERMINAL
Package

positional-lambda

Source

main.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   P  
Index Entry  Section

F
File, Lisp, positional-lambda.asd: The positional-lambda<dot>asd file
File, Lisp, positional-lambda/main.lisp: The positional-lambda/main<dot>lisp file
File, Lisp, positional-lambda/package.lisp: The positional-lambda/package<dot>lisp file

L
Lisp File, positional-lambda.asd: The positional-lambda<dot>asd file
Lisp File, positional-lambda/main.lisp: The positional-lambda/main<dot>lisp file
Lisp File, positional-lambda/package.lisp: The positional-lambda/package<dot>lisp file

P
positional-lambda.asd: The positional-lambda<dot>asd file
positional-lambda/main.lisp: The positional-lambda/main<dot>lisp file
positional-lambda/package.lisp: The positional-lambda/package<dot>lisp file

Jump to:   F   L   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %  
F   M   P  
Index Entry  Section

%
%assemble: Internal functions
%compute-lambda-list: Internal functions
%gensym-generator: Internal functions
%make-bindings-accumulator: Internal functions
%make-lambda-list-accumulator: Internal functions
%make-positional-gaps-filler: Internal functions
%make-positional-vars-accumulator: Internal functions
%make-walking-state-closures: Internal functions
%parse-body: Internal functions
%positional-ref-p: Internal functions
%processing-local-special-forms: Internal functions
%standard-expansion-process: Internal functions
%standard-local-special-forms: Internal functions
%walk: Internal functions

F
Function, %assemble: Internal functions
Function, %compute-lambda-list: Internal functions
Function, %gensym-generator: Internal functions
Function, %make-bindings-accumulator: Internal functions
Function, %make-lambda-list-accumulator: Internal functions
Function, %make-positional-gaps-filler: Internal functions
Function, %make-positional-vars-accumulator: Internal functions
Function, %make-walking-state-closures: Internal functions
Function, %parse-body: Internal functions
Function, %positional-ref-p: Internal functions
Function, %processing-local-special-forms: Internal functions
Function, %standard-expansion-process: Internal functions
Function, %standard-local-special-forms: Internal functions
Function, %walk: Internal functions

M
Macro, multiple-value-&bind: Internal macros
Macro, plambda: Exported macros
multiple-value-&bind: Internal macros

P
plambda: Exported macros

Jump to:   %  
F   M   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, positional-lambda: The positional-lambda package
positional-lambda: The positional-lambda system
positional-lambda: The positional-lambda package

S
System, positional-lambda: The positional-lambda system

Jump to:   P   S