V{ (as well as T{ { H{ and others) is a parsing word - it creates a new  
object in _parsing_ stage and compiles in _a reference_ to that object.
Without clone each invocation of a word using V{ }/T{ }/... would refer to  
same vector/tuple/hash/... - making it something like function's static  
variable.

Try this, for example:

TUPLE: boxed val ;
: i-am-static ( -- ) T{ boxed f 0 } [ 1 + ] change-val . ;
: i-am-not ( -- ) T{ boxed f 0 } clone [ 1 + ] change-val . ;
4 [ i-am-static ] times
4 [ i-am-not ] times


On Fri, 06 May 2011 21:12:06 +0600, Zhe Hu <[email protected]> wrote:

> what's the difference between:
>
> V{ } clone 3 suffix!
>
> V{ } 3 suffix!
>
> I guess my question is why do we need "clone", since it takes one object,
> but puts back just one object.
>
> Thanks,

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to