Also,
> :: <find-key> ( root target -- node new-root | 0 )
> ... ;
>
> : find-key ( key root -- node new-root | 0 )
The stack effect is being interpreted as `|' being an object on the stack
according to the stack checker. ( ) do not denote comments as in forth.
Try [ foo bar ] infer. in the listener to see what inferred affect of your
code might be.
http://docs.factorcode.org/content/article-inference.html
On Wed, Sep 23, 2009 at 6:16 PM, Slava Pestov <[email protected]> wrote:
> On Wed, Sep 23, 2009 at 7:20 PM, Hugh Aguilar <[email protected]>
> wrote:
> > In C the work-around is to return a pointer to a struct that contains the
> > two values (node and new-root), or to return a 0 (null pointer) in the
> event
> > that the key isn't found. This has to be done because C doesn't support
> > returning multiple values. Also, C is a strongly-typed language, so you
> > can't return a struct or a 0, because they are different types --- you
> can
> > only return a pointer to a struct or a 0, because the 0 is considered to
> be
> > a null pointer to any type. All of this is very kludgy though. I would
> > really want to avoid messing around with structs (or tuples) at all, and
> > just return the values on the stack, the way that I would do in Forth.
>
> First of all, don't use 0 to denote failure, use f (boolean false).
> You could return a tuple or f. Tuples are very lightweight syntax-wise
> and efficient at runtime too. The other alternative is to return 'f f'
> instead of just f in the failure case. The 'find' combinator takes the
> latter approach.
>
> > The problem in Factor seems to be related to returning a variable number
> of
> > values (two or one), rather than returning multiple values, which Factor
> > seems to be okay with.
>
> Correct.
>
> Slava
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk