[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggested new lambda-list syntax



I'm thinking of implementing the following new syntax for argument lists,
which I think is more Lispy than the existing one.

Anything in the argument list that is a symbol is the name of an
argument.  Anything that is a list has a car which is a keyword.
Keywords such as OPTIONAL, REST, AUX, KEY, QUOTE are followed by any
number of arguments (symbols or lists).  A default value is specified
by the keyword DEFAULT, as in (DEFAULT varname value specified-flag).
These constructs can be nested in any way that makes sense.

Arglists such as (X (REST Y Z) A (OPTIONAL A B)) which are nonsensical
would cause error messages.  

This new format facilitates extensions, such as (DATA-TYPE arg type),
(SPECIAL X Y (DEFAULT Z T)), or (LIST A B C) to do destructuring.
(LIST A (OPTIONAL B)) is also possible, leading to an interesting
idea: lambda-lists and SETF-able expressions can be generalized to be
the same kind of thing.

It is possible to support both this syntax and the existing one
because in the existing one it is illegal to have a list appear unless
&OPTIONAL, &KEY or &AUX has appeared first.  But ideally I think it
would be good to flush the existing one if it is ever practical to do
so.  Then there would be no reserved words in lambda lists.

Any comments?  Should the keywords have colons?  Be global like the
existing keywords?