|
From: Slava P. <sl...@fa...> - 2007-04-16 22:35:51
|
On 16-Apr-07, at 6:26 PM, Csaba Henk wrote:
> Hi!Based on the sample code in the concurrency docs, I put together
> this:
>
> !!!!!!!!!!!!!!!!! gentest.factor
> USING: kernel arrays quotations match concurrency math ;
> IN: gentest
>
> : decr-server
> receive {
> {
> { ?from ?tag _ }
> [ 1- dup ?tag swap 2array ?from send decr-server ]
> }
> } match-cond ;
Try putting the recursive call to decr-server after the match-cond.
> Why does that happen, given that Factor features TCO?
Because the recursive call is not a tail call; match-cond is not
calling the quotation in tail position.
The following is a tail call:
: foo ... foo ;
So is this:
: foo ... [ ... foo ] [ ... ] if ;
Because 'if' calls the quotation in tail position.
Slava
|