Factor/To do/Locals

Locals are a leaky abstraction. The leaks should be fixed as much as possible. [factor{! Fry and locals

[ 10 ] [
    0 '[ [let | A [ 10 ] | A _ + ] ] call .
] unit-test

Locals and macros which treat quotations as sequences

:: (funny-macro-test) ( obj quot -- ? ) { quot } 1&& ; inline
: funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ;

\ funny-macro-test must-infer
[ t ] [ 3 funny-macro-test ] unit-test
[ f ] [ 2 funny-macro-test ] unit-test

Fixed

! Smart combinators and wlet

:: wlet-&&-test ( a -- ? )
    [wlet | is-integer? [ a integer? ]
            is-even? [ a even? ]
            >10? [ a 10 > ] |
        { [ is-integer? ] [ is-even? ] [ >10? ] } &&
    ] ;

[ f ] [ 1.5 wlet-&&-test ] unit-test
[ f ] [ 3 wlet-&&-test ] unit-test
[ f ] [ 8 wlet-&&-test ] unit-test
[ t ] [ 12 wlet-&&-test ] unit-test

This revision created on Fri, 28 Nov 2008 01:22:14 by slava