Hi Slava,
thanks for your answer.

I saw `call(' and already used it, but in that way i have no static checker.
Im weak at low-level programming, but have an idea that maybe checker could
be extended to avoid inlining, when depending on stack-effect declaration.

For example, i could write it in standart way of inlining:

:: ?swap ( i j seq cmp-quot -- swapped? )
     i j [ seq nth ] bi@ cmp-quot call
     [ i j seq exchange t ] [ f ] if ; inline

:: (bubble-sort) ( seq cmp-quot -- continue? )
     seq length 1 - iota
     [ seq [ dup 1 + ] [ cmp-quot ?swap ] bi* ]
     [ or ] map-reduce ; inline

:: bubble-sort! ( seq cmp-quot -- seq' )
     [ seq cmp-quot (bubble-sort) ] loop seq ; inline

And with that checker extension i could avoid inling of `bubble-sort!'
(not of its helpers, they're still inlined), declaring stack-effect:

:: bubble-sort! ( seq cmp-quot: ( a b -- ? ) -- seq' )
     [ seq cmp-quot (bubble-sort) ] loop seq ;

Ander

> Hi Andrew,
> 
> Instead of declaring the combinator inline you can also use call(.
> (Refer to '\ call( help' for details).
> 
> As far as code size goes, each, map and other simple combinators
> expand into relatively small amounts of code. 'sort' is an exceptional
> case.
> 
> Slava
> 
> On Thu, Aug 12, 2010 at 2:41 AM, Андрей Полищук <[email protected]> wrote:
> > Hello,
> > im newbie to factor,
> > but i think i already like it,
> > but there's one thing that scares me:
> >
> > Every time when we have combinators we have to deal
> > with stack-effect checking of passed funarg(s) and as written
> > in manuals, and as done for standart combinators, the way to solve
> > this is to declare that combinator inline. But isn't it too inefficient, 
> > that
> > every call to map/reduce/each/sort/..etc will not simply jump to some 
> > routine, but
> > expand to mostly the same big amount of code?
> >
> > Thanks.
> > Ander
> >
> > ------------------------------------------------------------------------------
> > This SF.net email is sponsored by
> >
> > Make an app they can't live without
> > Enter the BlackBerry Developer Challenge
> > http://p.sf.net/sfu/RIM-dev2dev
> > _______________________________________________
> > Factor-talk mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/factor-talk
> >

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to