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

Concatenative language/Rest parameters

Stack languages do not immediately support variadic functions (like Common Lisp's &rest parameters) because there is no way to tell how many parameters must be taken from the stack; whereas all of the following is valid Lisp,

(+ a)
(+ a b)
(+ a b c)
(apply #'+ list)

In a stack language, the number of inputs to + must be fixed, and it only makes sense to have two inputs.

One approach is to make a new word which takes an integer, and operates on that many items at the top of the stack together. Factor's generalizations vocabulary has many such words. They are mainly intended for use in macros:

"a" 1 narray
"a" "b" 2 narray
"a" "b" "c" 3 narray

Another approach that is often used is to make a word which takes a sequence of values. If all the values are literal:

{ 5 } sum
{ 5 6 } sum
{ 5 6 7 } sum

or if not:

2 3 + 6 7 3array sum

This revision created on Sun, 9 Aug 2009 17:27:14 by mncharity (expanded "takes a sequence" example to clarify { } only works with literals)

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.