Hello!

  I'm struggling with some of the Factor's words. Mostly with `when-empty`, 
`if-zero` and similar. It's difficult for me to understand why they don't work 
sometimes, while their simpler counterparts (while, if) do work exactly as 
expected.

  Here's the latest installment of my struggle:

IN: scratchpad USE: crypto.xor [ [ empty-xor-key ] when-empty ]  infer.
( x -- x )

  Why is the stack effect as shown here? The documentation for `when-empty` 
says it takes `( seq quot -- )`. Therefore, I expect `[ [ empty-xor-key ] 
when-empty ]  infer.` to output `( x -- )`.

  When I modify the quotation passed to `when-empty` to be a no-op, I get a 
compilation error:
IN: scratchpad [ [ 1 drop ] when-empty ]  infer.
Error
The input quotations to “if-empty” don't match their expected effects
Input      Expected           Got
[ 1 drop ] ( ..a -- ..b )     ( -- )
[ ]        ( ..a seq -- ..b ) ( -- )

  That's completely weird to me. Is the stack effect in the documentation 
incorrect? Should it be `( seq quot -- seq )`?
  And why does it refuse to compile the second example with `1 drop`?

---=====--- 
 Александр

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to