On Wed, Oct 22, 2008 at 03:37:10PM +0100, Tomas Hlavaty wrote:
> (de foo "Prg"
> (when (car "Prg")
> (run (let @ (up '@) (cdr "Prg")) ) ) )
>
> Why this does not work?
Well, this is a hairy one ;-)
For one thing, the quote in the call of 'up' is too much. But this is
not the main problem.
The hard-to-explain thing is, that here (up @ 2) is needed:
(de foo "Prg"
(when (car "Prg")
(run (let @ (up @ 2) (cdr "Prg"))) ) )
Basically you were right to access '@' one level up.
But the implementation of 'up', 'eval' and 'run' is such that it looks
for binding frames that have '@' bound as their first symbol. The reason
is that we want to skip intermediate frames (with 'let', 'use', 'for'
etc.). Usually, only the binding frame for functional arguments start
with '@'. But you managed to create such a frame!
You can verify this by testing
(de foo "Prg"
(when (car "Prg")
(let (@ (up @) Dummy 7)
(run (cdr "Prg"))) ) )
Now '@' is not the first bound symbol in the frame (when seen from the
lower parts of the stack), but 'Dummy'. So (up @) works.
Perhaps I should think of another mechanism in PicoLisp-3
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]