This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug with letrec???


Mikael Djurfeldt <mdj@mdj.nada.kth.se> writes:

[internal defines -> letrec*]
>
> My position is that this would introduce more confusion than is
> gained.  There is never a hard need for the letrec* behaviour.  It's
> always possible to write such expressions in Scheme.

Yes. Likewise, you can always rewrite internal defines into other
Scheme expressions.  It's all about convenience.  In my view,
convenience is not at all unimportant.  I'm specifically thinking
about macros that want to expand into a sequence of internal defines.

Anyway, I agree that redfining internal defines might not be a good
idea.  Perhaps we could introduce a new kind of internal define, maybe
`define*' that translates into a letrec*.  I need to think more about
what happens when one mixes `define' and `define*' in one body.
`define*' would be unavailable in a pure R5RS environment, of course.

[ I think the name "define*" is already taken by ice/optargs, right? ]

> > Then, I would like to lift the requirement that defines must appear
> > at the beginning of a body, with no intervening non-defines.  I
> > think it is easy to specify the semantics for this and easy to
> > implement.
> 
> That semantics would be more complex: It would mean than one lexical
> environment (or "block") can be "split" into two by a `define':

I was more thinking about rewriting something like

    (let ()
      (define* foo 1)
      (baz)
      (define* bar 2))

into

    (let ()
      (letrec* ((foo 1)
                (dummy (baz))
                (bar 2))))
    
> (let ((x 1))
>   (if (zero? y)
>     (begin
>       (foo z)
>       (define u (bar v))
>       (baz u u))))

I think we should either give `if' (and `cond' and `case') `bodies' so
that they could contain `defines', or clearly give them `non-bodies'
that can not contain `defines'.  I.e., either the above form is
invalid ("Bad define placement"), or it is equivalent to

    (let ((x 1))
      (if (zero? y)
        (letrec* ((dummy1 (foo z))
                  (u (bar v)))
          (baz u u))))

But, yes, I'm not ready to take this to the Scheme community at large,
and thus, I'm not really pressing to include something like this into
Guile.  It could go horribly wrong.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]