I liked the original ideas and the discussions on this topic. Just a few
brief comments:
What you called ³eager² and ³lazy² macros seems to correspond pretty well to
³#define² macros in the C preprocessor and ordinary function definitions in
C. Am I right here? Clearly most languages could use a macro processor, and
in many it would be very useful. You might also call them ³compile-time² and
³run-time² operators (or something like that). I believe some languages even
have ³link-time² and ³load-time² macros, but these distinctions only make
sense in more complex systems. So, I would advise you to continue with the
two, but you do need some really convincingly useful examples of the eager
macros.
About the pattern matching operators, written in the ³before-and-after²
style, where (a b ‹ b a) implements swap, for example. I seem to remember a
few years back some discussion on how to extend this to handle list
manipulation. The pattern (a [b c D] -- b a [c a D] b [D]) would match a
stack whose top element is a list of at least two items, b and c, and which
also has a second element a. This operator would remove these two items from
the stack and then push the five items on the right of the ³--², which are:
b, the first element of the list, then a, the original second element,
then a list whose first two elements are c and a then the rest D of the
list, then b again, and finally, on top, the list which is just the rest D
of the list. Not a very useful example (contrary to my own advice), but
you get the idea. It would help if someone could remember when this
discussion occurred.
It looks a bit like Prolog, doesn¹t it? In fact all the stack-shufflers and
all list operators can be implemented in a Joy-in-Prolog using this style.
Sticking to the ³before/after² style, here are some familiar ones:
cons == (a [B] -- [a B])
uncons == ([a B] -- a [B])
first == ([a B] -- a)
rest == ([a B] -- [B])
Note that in the two examples all variables occurring to the right of
the ²--² were already bound on the left of the ³--². That need not be
so, but then we need some extra machinery. I will only give one
example. Suppose I have a list of at least 3 items on top of the stack,
and that third item is a number, and I wish to square it. In Joy I
would write
In a pattern matching Prolog-like Joy I would write
squarethird([x y z R] -- [x y w R])
w = z dup *
So the extra ³machinery² is precisely what in Prolog is the body of
a relation.
I cannot remember how far we went in our discussion some years back.
I have resisted the pattern matching mechanism for Joy mainly for
reasons of purity. But I am also aware how some of the pattern matching
languages allow very succinct code.
I hope what I wrote is of some use to the language smiths on this group.
- Manfred
[Non-text portions of this message have been removed]
... I had to look alpha-conversion up :-). Now I remember. I would have expected alpha conversion to appear even in the lazy case... Certainly if you allow...
I liked the original ideas and the discussions on this topic. Just a few brief comments: What you called ³eager² and ³lazy² macros seems to correspond...
... That's pretty nifty. I wrote some pattern matching routines for Factor a while back and for fun implented a 'shuffle' word that used it to do stack...
It is perhaps interesting to mention the equivalence of stack shuffling notation and lambda expressions (other languages) which was identified by Brent Kerby...
... Yes, although there's nothing interesting about the fact that those are equivalent to lambdas -- they are, prima facia, lambdas, since they create a...
... No, I would say they are more dynamic and very close to Lisp macros. ... Eager macros are very useful to efficiently generate or compile code. Let's say...
i've implemented several versions of this, in XY, and then again in F and G (http://www.nsl.com/k/f/f.htm) in F/G: A pattern is a list whose head is a scheme...
stevan apter
sa@...
Jan 5, 2007 3:12 pm
... I think you're probably right. I just did some work with the shuffle notation I proposed in my last post, which provided for stack shuffle and execution...
Hi Billy & all, It's been a while! Sorry this post is a little belated. I tried sending it last week, but something was wrong with my account (my concatenative...
... Thank you for putting the effort in. I have one more question. ... Ah! A light dawns. Thank you again. Your definitions make sense. ... Nice. Now I'm going...
Sorry; I said in my last post that I had one more question, and then I forgot to ask it. My question is: how does Okasaki's and Barker's work apply to this? ...
Billy and all, Sorry for taking so long to respond to this. When I first read your email, the server hosting Chris Okasaki's paper was apparently down. And...
... I agree -- and it was both instructive and reasonably fun to read. ... Indeed it did! I especially appreciate you including your reasoning. Not only do I...
... i thought it might be subliminal tribute to o[kasak]i....
sa@...
Feb 6, 2007 7:53 pm
... From: "William Tanksley, Jr" <wtanksleyjr@...> ... i think this should be 00101 0011 1 1 = [] q k k i've posted an interpreter for 01 at: ...
stevan apter
sa@...
Feb 8, 2007 11:15 pm
... [A] [] q k k = [[A]] [A] k k = A k Too many k's. What might be messing things up is how you treat the [A B] term in the result of 'q'. In this quotation,...
... From: "William Tanksley, Jr" <wtanksleyjr@...> To: <concatenative@yahoogroups.com> Sent: Thursday, February 08, 2007 11:54 PM Subject: Re: [stack]...
stevan apter
sa@...
Feb 9, 2007 12:54 pm
... This is one of the things that confuses me about this notation -- but it's something you have to learn. The reason it's confusing to us is that it's a...
... [:] ... [:] ... my confusion was purely notational: i didn't realize that "A B" meant (what i would write as) "A^B", although the left-hand-side of the...
sa@...
Feb 9, 2007 4:38 pm
... Included at the end of this post. ... Indeed. Although I'm also interested in genetic systems, my main interest is in understanding languages for use by...
My apologies to the many people (I hope) reading this list and hoping for something useful. This stuff is a LONG way from usefulness. I hope that it will...
... Wow! That's much better. Nice work. ... Well, what exactly do you mean by that? There's certainly one combinator which is shorter in my {o,i}, namely "i"....
Billy & all, I hacked at my old Joy searcher for a while and was at last able to persuade it to deal with improper combinators; so I've been able to determine...
... Thanks, but obviously it builds on your work -- you actually know what you're doing, and you get all the credit for making it make sense. I suspect that...
i would be extremely interested in reading a description of the algorithm. (my dog ate my credit card) ... From: "William Tanksley, Jr" <wtanksleyjr@...>...
stevan apter
sa@...
Feb 9, 2007 10:03 pm
... Oh, yeah, I forgot to mention that. It's at http://www.tunes.org/~iepos/joys.zip (it's linked from the article "Theory of Concatenative Combinators"); I...
... It basically works by trying all programs of size 0 (There aren't too many of these :-) ), then all programs of size 1, and so forth, testing each program...
thanks brent as usual, work that you consider throw-away contains more insights than can fit in a standard published article, much less the margins of one. ......
stevan apter
sa@...
Feb 11, 2007 12:07 am
... I'm looking forward to your genetic system -- one would expect that it would be useful for the same purpose. Perhaps you should tailor a version of it to...