[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improper lists in macros [WAS: none]
This page is part of the web mail archives of SRFI 26 from before July 7th, 2015. The new archives for SRFI 26 contain all messages, not just those from before July 7th, 2015.
> felix wrote:
> Regardless of that I would propose to change
> the syntax to something like
> (curry <procedure> (<constant-or-slot>* [. <>]))
> (curry (<constant-or-slot>* [. <>]) <procedure>)
> That resembles a lambda-list more closely, IMHO.
Unfortunately, I fail to see the similarity between the syntax
you propose and the syntax of a lambda-_expression_:
Concerning your first proposal: An application of a procedure is
written in Scheme as (proc arg1 .. argN) which is different from
(proc (arg1 .. argN)) which applies arg1 to arg2 .. argN.
Concerning your second proposal: The <constant-or-slot>-list
also contains constants, which might simply be identifiers.
For example, (curry (x y z) list) as you propose, does not mean
(lambda (x y z) (list x y z)) but rather (lambda () (list x y z)).
Also the syntactic inversion of procedure and arguments
might become confusing in nested expressions.
However, I once thought about the syntax
(curry (<proc> <const-or-slot>* [ . <> ]))
which shows the actual application _expression_ explicitly.
But as the additional braces do not add semantics or
peace of mind, I simply left them out.
The other reason why I left out any additional parentheses in the
macro 'curry' is the nice syntactic resemblance between 'curry'
and the standard Scheme procedure 'apply' (R5RS, Sect. 6.4).
In fact, if there are no slot at all, for example (curry list 1 2), then
the result is simply (lambda () (apply list 1 2)). As 'curry' is indeed
only partial application, this resemblance is more than an accident
and helps me recall what the macro does.
Hence, I still prefer the syntax as defined in the original SRFI document.
Does this discussion clarify what is behind my choice of syntax
and can you live with that?