Concatenative language
Other languages
Computer Science
Meta
= Mentors = [[Slava Pestov]] [[Joe Groff]] = Technical outline = Factor has a %locals% library which implements lexical variables and closures over the underlying stack-based computation model. It adds simple syntax for lexical variable bindings that integrates into the surrounding concatenative model: [{1 2 + :> three ! bind 3 to "three"}] [{3 4 [ + ] [ - ] 2bi :> ( seven negone ) ! bind 7 and -1 to "seven" and "negone"}] It also provides a mechanism for building datastructures from lexical values using literal syntax: [{1 2 + :> three { three 4 5 } ! evaluates to { 3 4 5 }}] The locals syntax currently lacks the ability to destructure aggregates. The syntax could be extended to destructure common classes of Factor aggregates, such as sequences, assocs, and tuples: [{3 iota :> { zero one two } ! bind zero, one, and two to 0, 1, and 2}] [{image new RGBA >>component-order unsigned-char >>component-type :> T{ image { component-order order } { component-type type } } ! bind "order" to RGBA and "type" to unsigned-char}]
Describe this revision:
Save