bug-guile
[Top][All Lists]
Advanced

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

bug#17940: Nitpick: (lambda () (begin)) errors


From: Taylan Ulrich Bayirli/Kammer
Subject: bug#17940: Nitpick: (lambda () (begin)) errors
Date: Sat, 05 Jul 2014 01:39:04 +0300

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]