Re: [stack] Code Transformation Problem (possibly monadic?)

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Christopher Diggins <[email protected]> wrote:
> William Tanksley, Jr <[email protected]> wrote:
> > Christopher Diggins <[email protected]> wrote:
> >  At this point, though, I have to stop and wonder what your problem
> >  really means. When you say "each function applies to the stack below
> >  the top value", do you mean what I just wrote, or do you mean that the
> >  ENTIRE SEQUENCE ignores the value which was on the top just prior to
> >  execution of the sequence, except for 'm', which for some reason sees
> >  the value but doesn't destroy it (so that the next 'm' can also see
> >  it)? That's a very complex semantics. Why do it?

> Rewrite code to pass values without changing the order of operations.

Oh. I don't really get it... I understand the concept of partial
application, but I don't know how you're trying to model that here. I
certainly don't see any unambiguous semantic model behind what you're
asking for, so my guess is likely going to miss the mark.

But let's see if we can figure it out anyhow.

> >  However, here's a transform which appears to meet your request.
> >  [a] dip [b] dip dup [m] dip [[c m d e]] dip [f] dip [g] dip

> "c", "d", and "e" would take the top of the stack as an unintentional argument.

The top of stack wouldn't be available to the function [c m d e] --
'dip' hides it.

However, I think I might be able to guess another possible semantics
you might want. You want all 'm's contained in the source to somehow
receive the one treatment, and all the other functions to receive
another treatment. The problem is that Joy's quotations make things
complex by nesting semantics. The obvious 'simple' solution is to
start by flattening your function (using the transform we talked about
earlier, while the group was discussing flatness); then replace each
function or quoted function with its new semantics. I've still got to
figure out what the correct semantics are for this transform; I
haven't figured that out.

(I also need to remember or look up HOW to flatten arbitrary Joy; we
had an algorithm for this explained to us, I believe by iepos, but I
can't seem to find it. The goal is simple enough: I want to reduce
arbitrarily nested Joy to a linear list of symbols and quoted symbols.
Doing this will allow me to figure out only four semantics: one for
'm', one for '[m]', one for 'X', and one for '[X]', where 'X' stands
for any symbol other than 'm'.)

Hmm... Let me ask you a set of questions.

What's the correct transform for an expression consisting ONLY of a
single one of the following pairs: 'm x', 'x m', '[m] x', '[x] m', 'm
[x]', 'x [m]', '[m] [x]', '[x] [m]'? Pick a few that you think are
representative, don't bother answering them all unless you want.

For example, I think the transform of 'm x' would be 'dup [m] dip [x] dip'.

While you're answering that, I'll try to derive the algorithm for
flattening a quotation.. I have a long train commute ahead of me.

> - Christopher

-Wm
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.