On 12/6/07, Slava Pestov <[EMAIL PROTECTED]> wrote:

> No, in fact the following two are different:
>
> : foo A [ B ] when C ;
> : foo A [ B ] [ C ] if ;
>
> So the following two are different also:
>
> : foo A [ B foo ] when C ;
> : foo A [ B foo ] [ C ] if ;

Yes, but the last one is equal to:

: foo A [ B foo ] when ;

and following sequence:

foo C

'C' part doesn't logically belong to the loop, it just executes
once after (zero or more) loop repetitions, on any conditions.

Example:

( scratchpad ) : foo dup 3 < [ dup . 1+ foo ] [ . "done" print ] if ;
( scratchpad ) 1 foo
1
2
3
done
( scratchpad ) : bar dup 3 < [ dup . 1+ bar ] when ;
( scratchpad ) 1 bar . "done" print
1
2
3
done

A = 'dup 3 <'
B = 'dup . 1+'
C = '. "done" print'

-- 
Cyril Slobin <[EMAIL PROTECTED]> `When I use a word,' Humpty Dumpty said,
http://wagner.pp.ru/~slobin/ `it means just what I choose it to mean'

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to