Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

Factor/To do/Locals

Locals are a leaky abstraction. The leaks should be fixed as much as possible.

Open problems

Locals also don't work with undo. On the left hand side, they should bind locals.

There is still an issue with locals and fry:

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

Fixed

Locals expands macros at parse time which is a problem in this case:

USING: math sequences locals combinators.short-circuit.smart ;
IN: foo

GENERIC: foo ( a -- b )

M: string foo reverse ;
M: integer foo neg ;

:: bar ( a -- b )
   { [ a foo ] } && ;
  • Don't expand all literals, only those with locals in them.

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
! Fry and locals

[ 10 ] [
    [let | |
        0 '[ [let | A [ 10 ] | A _ + ] ] call .
    ]
] unit-test
! 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 Sat, 7 Mar 2009 02:07:04 by slava

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.