On Fri, 2011-05-06 at 19:39 -0700, Slava Pestov wrote:
> Hi Matt,
> 
> On Fri, May 6, 2011 at 6:51 PM, Matt Edlefsen <[email protected]> wrote:
> > As for mapping instead of reducing, the issue I ran into was that map
> > seems to try to wrap the result in the same sequence type that the input
> > was. That works great for vectors, but when the sequence is a string:
> > "abcd" [ '[ _ = ] ] map
> > then you have a problem.
> 
> You can do this:
> 
> "abcd" [ '[ _ = ] ] { } map-as

Thanks, worked as advertised.

> > So is a dynamic quotation just any quotation that has been
> > "returned" (so to speak) by a non-inline function?
> 
> Yes. If the quotation is not literal, and was not constructed by using
> fry, curry or compose, then the Factor compiler has no way of
> statically proving its stack effect. So 'call' doesn't work and you
> must use call(.
> 
> > This part I think is still a bit beyond me. The "define-transform" page
> > says it will only apply the transform if the argument is a literal, but
> > the normal 1|| calls "call" which also requires the argument to be a
> > literal.
> 
> The actual word definition for 1|| is only used by the non-optimizing
> compiler. Inside compiled word definitions, only the transform is
> used.
> 
> The optimizing compiler uses static stack effects to enable many
> optimizations on the compiled code. Essentially, stack manipulation is
> converted into single-assignment register operations. The
> non-optimizing compiler doesn't do any of this; it just executes all
> the code on a real stack.
> 
> Don't worry about define-transform; it's slightly lower-level than
> MACRO: and only needed if you want the optimized and non-optimized
> behavior of your word to differ. Your code should only use MACRO:.
> 
> Slava

Makes sense.  I changed contains-any? to
MACRO: contains-any? ( elts -- quot ) seq>contain-seq '[ _ 1|| ] ;

But that only works if elts is literal, so I changed it back to the
call( version.

Thanks!

Matt Edlefsen


------------------------------------------------------------------------------
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