Ricardo,

The stack effect of the 'ortho*' combinator we ended up with is:

    ortho* ( gadget left right bottom top quot -- )

Six inputs is a alot. For me that's usually a signal to look for another 
abstraction. The left, right, bottom, and top values seem related. :-)

    TUPLE: <extent> left right bottom top ;

Now, 'ortho' can have the effect:

    ortho ( gadget extent quot -- )

Now 'draw-gadget*' looks like:

    M: <sine-gadget> draw-gadget* ( sine -- )
      -10 10 -10 10 <extent> boa
        [ -10 10 0.5 <range> [ dup sin 2array ] map line-strip fill-mode ]
      ortho ;

If I feel like being explicit about what's going on with the extent values, I 
can use tuple literal syntax:

    M: <sine-gadget> draw-gadget* ( sine -- )
      T{ <extent> { left -10 } { right 10 } { bottom -10 } { top  10 } }
        [ -10 10 0.5 <range> [ dup sin 2array ] map line-strip fill-mode ]
      ortho ;

In fact, here's a summary of five ways you can construct a tuple, using 
<extent> as the example:

    <extent> new
      -10 >>left
       10 >>right
      -10 >>bottom
       10 >>top

    -10 10 -10 10 <extent> boa

    T{ <extent> f -10 10 -10 10 }

    T{ <extent> { left -10 } { right 10 } { bottom -10 } { top 10 } }

    [let | LEFT   [ -10 ]
           RIGHT  [  10 ]
           BOTTOM [ -10 ]
           TOP    [  10 ]  |

      T{ <extent> f LEFT RIGHT BOTTOM TOP } ]

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to