guile-devel
[Top][All Lists]
Advanced

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

Re: @bind


From: Neil Jerram
Subject: Re: @bind
Date: 18 Aug 2001 11:32:42 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Marius" == Marius Vollmer <address@hidden> writes:

    Marius> Neil Jerram <address@hidden> writes:
    >> >>>>> "Marius" == Marius Vollmer <address@hidden> writes:
    >> 
    Marius> Does anyone know how address@hidden' is supposed to be used?
    >>  I think it's connected with the emacs lisp support.

    Marius> Yes.  Looking at the implementation, address@hidden' creates new
    Marius> global variables in the current module, and puts values
    Marius> from the existing lexical environment into them.  That
    Marius> lexical environment is not checked for proper structure at
    Marius> all, so that

    Marius>     (@bind (a) #t)

    Marius> will segfault immediately when run on top-level.  It
    Marius> really seems like it bit-rotted away.

Well it was probably intended only to work in conjunction with
Mikael's elisp transformer code (which I've now found again).

It turns out that that combination _has_ bit-rotted a little, but not
for this reason; rather, because it transforms an elisp (lambda (x y
z) ...) into

(lambda (% % %)
  (@bind (x y z)
    ...))

which now produces a `duplicate formals' error. :-)

Besides producing an error, this transformation is IMO rather ugly.
Also the associated transformation code doesn't currently support
&optional and &rest.

I'd like to change the transformation to

(lambda %
  (binder %)
  ...)

where `binder' understands normal, &optional and &rest formals and
uses address@hidden' to set up the appropriate bindings using bits of %.

This change will work well with your proposed redesign of @bind ...

    Marius> I think I take the liberty and re-design it completely.
    Marius> Like so

    Marius>     (@bind ((var val) ...) body ...)

    Marius> will assign the `val's to the global variables named by
    Marius> `var's (symbols), creating them if they don't exist,
    Marius> executes body, and then restores the previous values of
    Marius> the `var's.  Additionally, whenever control leaves body,
    Marius> the values of the `var's are saved and restored when
    Marius> control returns.  It is an error when a symbol appears
    Marius> more than once among the `var's.

This is IMO much cleaner than how @bind works now.  Do you think
you'll have time for this soon?  I could have a go, but it is the
evaluator ... :-(  One detail: in the case where @bind creates a new
variable on entry, should it destroy that variable on exit?  (I don't
think the current SCM_IM_BIND code does this.)

        Neil




reply via email to

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