The answer is that you can't use [let to bind a symbol to multiple
values. [let doesn't care how many values the quotation puts on the
stack, it just takes the top of the stack and binds it to the
variable. So the following are all equilvalent,

1 2 [let | x [ ] | x drop ]
1 [let | x [ 2 ] | x drop ]
[let | x [ 1 2 ] | x drop ]

Slava

On Sat, Jan 31, 2009 at 6:04 PM, Alex Drummond
<[email protected]> wrote:
> Hi,
>
> Not sure if I'm misunderstanding how let is supposed to work, but I'm
> getting some strange behavior when using it to bind symbols to
> multiple values. Specifically, the 'good' word works as expected, but
> the 'bad' word doesn't:
>
> : good ( -- v ) [let | x [ 1 2 ] | x drop ] ;
> : bad ( -- v ) [let | x [ 1 2 ] | x 2drop x drop ] ;
>
> 'good' returns 1, as expected, whereas 'bad' leads to a compile error
> and adds nothing to the stack.
>
> Alex
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to