On Wed, Oct 22, 2008 at 05:23:40PM +0100, Tomas Hlavaty wrote:
> 
> > The hard-to-explain thing is, that here (up @ 2) is needed:
> >
> >    (de foo "Prg"
> >       (when (car "Prg")
> >          (run (let @ (up @ 2) (cdr "Prg"))) ) )
> 
> (up @ 2) is not right, it sets @ to 2 which makes the example
> (and 2 (foo T (+ 1 @ 3))) pass.   If you try (and 4 (foo T (+ 1 @ 3)))
> it will not return the right value.  That's detail anyway, I'm with you now.

Oops, right! This worked only by chance :-)

The correct syntax to access the second level would be: (up 2 @)

But still I was writing nonsense, as going up two levels is not what we
need here.


> There seems to be difference between (let @ (up @) ...) and
> (let (@ (up @)) ...):

Yes. (let @ (up @) ..) and (let (@ (up @)) ..) are the same (i.e. only
'@' is bound in that frame), but if there is another symbol bound, it is
different:

   (let (@ (up @)  Dummy 7)

This gives a stack frame

   +----------------------+
   | Old value of '@'     |
   +----------------------+
   | '@'                  |
   +----------------------+
   | Old value of 'Dummy' |
   +----------------------+
   | 'Dummy'              | <- Frame
   +----------------------+

'up', 'eval' and 'run' look at the *first* symbol in the frame. If it is
'@', it assumes that it is the bindings of function arguments, otherwise
'let' etc.

Now, unfortunately, a 'let' with a single '@' will produce such a frame.


The is based on the assumption that it normally it makes no sense to
bind '@' locally, as this is a very volatile value, and bound in each
function invocation anyway.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to