Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Cat
  • Cognate
  • colorForth
  • CoSy
  • Deque
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Forth
  • Freelang
  • Gershwin
  • Joy
  • Kitten
  • lang5
  • Lviv
  • min
  • mjoy
  • Mlatu
  • Ode
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Quackery
  • r3
  • Raven
  • Retro
  • Staapl
  • Stabel
  • Trith
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Other languages

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

Computer Science

  • Type systems
  • Language paradigms
  • Compilers
  • Interpreters
  • Garbage collection

Meta

  • Search
  • Farkup wiki format
  • People
  • Etiquette
  • Sandbox

Factor/GSoC/2010/Destructuring locals bindings

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

This revision created on Thu, 4 Mar 2010 00:22:52 by jckarter

Latest Revisions Edit

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