Re: [stack] S-K Construction of Dip?

Manfred Von Thun <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <C2285E02.835%[email protected]>
Here is a flat concatenative language which I shall call L.
After a lot of discussions on this group I now have some intuitive
understanding of what
a flat language is. I shall discuss this language L in relation to Joy.

The problem seems to be how to handle apparent non-flatness due to
quotations/lists, which can be nested. I need to introduce the notion of a
waiting room, or ante-room, or briefly, a foyer. This is where incoming
items form a queue (perhaps similar to Stevan¹s Y queue in his XY language).
At certain times a queue in a foyer gets sent elsewhere and the foyer is
destroyed. A foyer is created by the special item ³[³, and destroyed by the
special item ³]².  I also need a notation for describing foyers: a newly
created empty foyer is written <>, an after a ³dup² item arrives the foyer
is written <dup>, after a ³*² item arrives it is written <dup *>. But a
foyer is not a list, in fact a foyer can contain lists. Foyers cannot be
nested, but there is a stack of foyers: I shall write this stack with the
topmost item on the right.  When a foyer is destroyed by ³]², the contained
queue is sent to the foyer below as a list.

Here is a contrived example to illustrate several nestings. Let the program
be

9999 [ [2 3] [dup *] map ] dip .    # should produce:  [4 9]  9999

The program starts with a stack containing just one empty foyer. I shall now
trace the execution of the program by writing each step on a separate line,
followed by a picture of the stack of foyers, followed by a comment.

         <> # start with stack of just one empty foyer
9999  <9999>  # put 999 at end of top foyer top foyer
[        <9999> <>  # start a new foyer
[        <9999> <>  <> # start a new foyer
2        <9999> <> <2> # put 2 at end of top foyer
3        <9999> <> <2 3> # put 3 at end of top foyer
]         <9999> <[2 3]>  # pop top foyer, put is content as list into foyer
below
[         <9999> <[2 3]> <>  # start a new foyer
dup     <9999> <[2 3]> <dup> # put dup at end of top foyer
*         <9999> <[2 3]> <dup *> # put * at end of top foyer
]          <9999> <[2 3] [dup *]> # pop top foyer, put content as list into
foyer below
map     <9999> <[2 3] [dup *] map]  # put map at end of top foyer
]          <9999 [[2 3] [dup *] map]> pop top foyer, put its content as list
into foyer below
dip       <9999 [[2 3] [dup *] map] dip> put dip at end of top foyer
.           pop the top foyer, execute its contents as a Joy program

The behaviour of any item such as * and dip always depends on what it finds
on the stack: if it is a foyer, join the queue, otherwise multiply or dip as
normal for Joy. There is not much one can do with a foyer: create and
destroy with ³[³ and ³]², or accept items into the queue.

This is the flat concatenative language L. But one could invent an extension
L++ which allows other things to be done to foyers ­ writing them out,
adding things to a queue by means other than a newly arriving item, or
perhaps immediate action macros. But I do not want to explore this here.

Is L flat enough? It is a language from stacks to stacks, using
concatenative notation. The behaviour of a whole program up to its
termination as a Joy program is to compute a function, and all parts compute
functions, and function computed by the whole is the composition of the
functions computed by the parts. And of course if any parts get snipped out,
the remainder will compute a function which may well be the empty  (nowhere
defined)
composition of the functions computed by the remaining parts.













[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.