[racket-dev] flatten-begin

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Jul 20 03:36:02 EDT 2014

On Sun, Jul 20, 2014 at 1:27 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Fri, 18 Jul 2014 09:52:26 -0500, Robby Findler wrote:
>> Unless someone knows why it is a bad idea, how about adding a #:all?
>> argument that flattens all the way down?
>>
>> I don't see many uses of flatten-begin in our tree, but the one in
>> compatibility/package sure looks like it could use the #:all?
>> argument.
>
> I don't think so. Eagerly flattening would break examples like
>
>    (begin
>     (define begin +)
>     (begin 1 2)))
>

Oh, I see I missed the call to local-expand in the loop, sorry.

But what is this supposed to do at the REPL? DrRacket and Racket at
least agree, but it isn't what I would have predicted:

> (begin
    (define begin +)
    (begin 1 2))
. begin: function application is not allowed;
 no #%app syntax transformer is bound in: (begin 1 2)

Are they doing the right thing?

(Inside a module we get the expected 3.)

Robby

Posted on the dev mailing list.