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

Pipeline style

A very common idiom is "pipeline code". The simplest code in a stack language is where each word takes a single value from the stack and leaves a new value there; such words can be chained together much like commands in the Unix shell. For example, here is some Factor code:

"/etc/passwd" ascii file-lines
[ "#" head? not ] filter
[ ":" split first ] map

This is very similar to the following Unix shell script:

cat /etc/passwd | grep -v '^#' | sed -e 's/:.*//'

However of course Factor is more expressive and has a simpler syntax.

A variation on pipeline code can be found in the UI framework. Here, we are building a tree of gadgets, so it is not quite a pipeline: we create child gadgets, build them up, then add them to the parent using add-gadget ( parent child -- parent ). Here is an elaborate example:

<pile>
    "Hello" <label> add-gadget
    "Click me" [ drop beep ] <bevel-button> add-gadget
    <shelf>
        "A" <label>
            red solid >>interior
        add-gadget
        "B" <label>
            green solid >>interior
        add-gadget
        "C" <label>
            green solid >>interior
        add-gadget
    add-gadget
5 <border>
    black solid >>boundary
"Test" open-window

Notice it reads almost like a declarative description, but really it is just stack code.

This revision created on Fri, 2 Jan 2009 22:06:30 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.