Re: [stack] EWD 28: Djikstra's sort-of-concatenative language

Stevan Apter — 2007-07-31 12:24:52

see section 6, "Names", in www.nsl.com/k/f/f.htm.

! is f's equivalent of joy's i, and ' is the quotation operator, so
'+! leaves + on the stack, just as you suggest.

in f, 2 3 + leaves 5 on the stack, as you would expect, but 2 3 plus,
where plus is [+] leaves 2 3 [+] on the stack, so to evaluate, you
must say 2 3 plus!.

'x takes x and pushes [x] onto the stack. [X]! takes X and prepends
it to the queue (whence elements of X are serially evaluated.)

it's interesting (but not surprising) to learn that djikstra was
there first.

also, see van oormerssen's language 'false': http://wouter.fov120.com/false/index.html

----- Original Message -----
From: "kuwabatake" <kuwabatake@...>
To: <concatenative@yahoogroups.com>
Sent: Monday, July 30, 2007 6:33 PM
Subject: [stack] EWD 28: Djikstra's sort-of-concatenative language


> I find Djikstra's writings very interesting, and I stumbled on this:
>
> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD00xx/EWD28.html
>
> In the (short) paper, Djikstra describes a stack-based arithmetic
> language. At first, he has two types of ``words'' that can be
> concatenated: number words and operator words. When a number word is
> encountered, the number is pushed onto the stack; when an operator
> word is encountered, the operation is performed on the top of the
> stack and the result pushed. So far, so good; we could think of this
> language in the Joy-like way by reframing all words as functions stack
> -> stack.
>
> The really interesting part comes in the middle of the paper: Djikstra
> proposes to make operator words behave just like number words, simply
> pushing the operator onto the stack. He then introduces the special
> word `E'(for evaluate) which, if there is an operator on top of the
> stack, makes the operator perform its action. In this language,
> pushing 1 2 + would give the stack
>
> 1 2 +
>
> but then pushing an E would give the stack
>
> 3
>
> The result is that operators can sit on the stack just like numbers
> and `literals'. Djikstra goes on to introduce an environment of bound
> variables, but that doesn't interest me as much. To me, the
> introduction of E is a really significant idea. In Joy, popping + out
> of a list with
>
> [+] first
>
> is sort of messy; a meaningless token is now floating on the stack,
> needing a new quotation to be part of before it can be used in a
> meaningful way and muddying the expression-oriented way of looking at
> Joy. If Joy's + was instead defined as
>
> + == '+ i
>
> where '+ is primitive, then the single symbol '+ could be treated as a
> quotation, executable by combinators. The ambiguous symbol + is now
> just an ordinary definition. A language whose primitives are all like
> this would be somewhat Floy-like, where '+ replaces [+] (sort of...
> the analogy is a little complicated.)
>
> In short: how about a language in which every word puts itself onto
> the stack, except for the `special' word i, which executes the
> function on top of the stack?
>
> Whew, long post. Thoughts?
>
> ~Daniel
>
>