>
>   Type propagation? I didn't know there you could specify argument types
> in Factor! Where is it described, how do I use it?
>

The short answer is there are two main ways to do type propagation:

1) the input to an inline word has a known type (this is what I was
referencing)

2) the "typed" vocabulary is used to tell a word what types to expect and
specialize on

    http://docs.factorcode.org/content/article-typed.html

The longer answer includes such details as some words the compiler can
infer output-types, for example knowing that <string> creates a string
object:

    IN: scratchpad USE: compiler.tree.debugger

    IN: scratchpad [ 5 CHAR: a <string> string? ] optimized.
    [ \ t ]

And in the case of numbers, the compiler can support interval analysis to
know that a number is in a specified range, for example that in the "else"
quotation that the number must be less than or equal to zero (thus not
being greater than 5) so it can infer ``f`` without doing a computation:

    IN: scratchpad [ dup 0 > [ 12 > ] [ 5 > ] if ] optimized.
    [ dup 0 > [ 12 > ] [ drop f ] if ]
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to