Disclaimer: this is probably just a nitpick.

On guile-user someone brought up that (lambda () (begin)) errors,
arguably counter-intuitively:

http://lists.gnu.org/archive/html/guile-user/2014-07/msg00005.html

After much investigation over this trivial matter, I found that while
it's compliant with the RnRS (it's unspecified), it means Guile
extends the RnRS grammar in an "unexpected" way.  According to R5 and
7RS:

<lambda expression> -> (lambda <formals> <body>)
<body> -> <definition>* <sequence>
<sequence> -> <command>* <expression>
<expression> -> (other stuff) | <derived expression>
<derived expression> -> (other stuff) | (begin <sequence>)

meaning that the "(begin)" in that lambda body can be matched up to
<derived expression>, where it then almost matches the `begin' form
but fails only because in the RnRS grammar it must have at least one
expression (see <sequence> again; this is also reflected in section
4.2.3 where this `begin' form is explained; its template clearly shows
it must have at least one expression operand).

Guile on the other hand *generally* allows the expression-begin to
have zero operands, having it return *unspecified*.  So one would
expect it to work here as well, since one expects that this is a small
incremental extension to the RnRS grammar, but that's not the case.

If I'm not mistaken, `expand-body' in psyntax would be the place to
tackle this, and from a quick glance I'm guessing the benefit/effort
ratio for changing this is not very high. :-)

Taylan



  • bug#17940: Nitpick: (lambda () (begin)) error... Taylan Ulrich Bayirli/Kammer

Reply via email to