Re: [stack] Concatenative macros?

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
[email protected] <[email protected]> wrote:
> i think i've formulated a version which captures your requirements.

I think I see some ambiguities.

> since setting down the rules is more difficult than grasping the
> notation by way of examples, let me do that first:

Agreed.

>       car         [aB]-a
>       cdr         [aB]-B
> B is the rest of the list [a ...].  that is, B is [...].

I do like your notation of uppercase meaning "the rest of the list".

>       cons        aB-[aB]
> B on the left matches a list.

But this is a contradiction. B on the left doesn't match a list; it
matches "the rest of the list". It's true that at the end of the list
"the rest of the list" happens to be a CDR, which is enclosed in a
list -- but our notation hides that fact, and we shouldn't expect the
user to know it.

Therefore I propose that uppercase on the left not match a list, but
rather match "the rest of the list" (and not be defined outside of a
list, nor if used twice inside a list).

> on the right [aB] is the list
> with a as the first element, and B as the remaining elements.

I propose that uppercase on the right side mean execution, always.

So your example
>       cons        aB-[aB]
becomes (I suggest):
     cons        a[B]-[ab]

> on either side, a list may contain at most one upper-case letter:
>       [aBc]

I agree with this, because obviously "the rest of the list" doesn't
make sense when used more than once per list. Your followup message
contradicts this because I think you were believing that uppercase
meant "there is a list here", but that's not accurate. If you want to
match a list, you can make it explicit, like this:

 [a[B][C]]-[c][b]

>       uncons      [aB]-aB

And in my proposed notation,

      uncons      [aB]-a[b]

It's an implementation detail that B is entirely contained within the
CDR list of the original list, so no new list needs to be formed.

>       i           A-a
> A matches a list, a is A i.

This isn't accurate, because 'i' must execute each item, not merely
unquote a list. It's also ambiguous what A means here -- you defined
it as "rest of the list", but you're using it here as "a list".

I propose:

      i           [A]-A

First, we see that the unquoting is explicit, but different from
execution. Second, we see that execution is expressed by uppercase
letter on the right side. This means that uppercase means something
different on the left and right side -- but this seems to me to be
reasonable, since the left side is a pattern, while the right side is
not.

>       dip         aB-ba

Again, I would express this as:

  dip  a[b]-Ba

> so then what do the following shuffles mean?

>       a-A
> the first could be quotation; i.e. a-[a].

In my notation, this is the general form of 'i'; it executes anything,
list or non-list.

>       [aB]-[ab]
> the second could be disquotation without execution:
>       [2 [3 +]] [aB]-[ab] -> [2 3 +]

In my notation that would be identity.

If you want disquotation without execution, you'd write:

  [a[B]]-[ab]

> i don't see any problem extending the notation to handle nested
> lists on either side.

Correct, unless we confuse our notation with CDR notation. In our
notation the tail of a list is not _written as_ a list -- it's a group
of items. It's an array style notation. If we adopt your style, every
list would have a CDR of [], so the two left-hand expressions [a[]]
and [a] would match the same lists. I think it gets worse, because it
would become difficult (ambiguous) to express lists that contain the
empty list.

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