Concatenative language
Concatenative topics
Concatenative meta
Other languages
Meta
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, [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: [factor{"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: [factor{{ 5 } sum { 5 6 } sum { 5 6 7 } sum}] or if not: [factor{2 3 + 6 7 3array sum}]
Describe this revision:
Save