Skip to search.
concatenative · Discuss the concatenative variety of computer languages: Joy, Forth, Postscript

Group Information

? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

  Messages Help
Advanced
Concatenative macros?   Message List  
Reply Message #3125 of 4928 |
Re: [stack] Concatenative macros?


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

squarethird == uncons uncons unswons dup * swons cons cons

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]




Tue Jan 2, 2007 9:08 am

maggethun
Offline Offline
Send Email Send Email

Message #3125 of 4928 |
Expand Messages Author Sort by Date

... 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...
William Tanksley, Jr
wtanksle Offline Send Email
Dec 27, 2006
5:05 pm

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...
Manfred Von Thun
maggethun Offline Send Email
Jan 2, 2007
9:17 am

... 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...
Chris Double
doublecnz Offline Send Email
Jan 2, 2007
1:20 pm

It is perhaps interesting to mention the equivalence of stack shuffling notation and lambda expressions (other languages) which was identified by Brent Kerby...
Christopher Diggins
cdiggins.geo Offline Send Email
Jan 4, 2007
5:32 pm

... Yes, although there's nothing interesting about the fact that those are equivalent to lambdas -- they are, prima facia, lambdas, since they create a...
William Tanksley, Jr
wtanksle Offline Send Email
Jan 4, 2007
6:53 pm

... 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...
Robbert van Dalen
r_v_dalen Offline Send Email
Jan 5, 2007
9:55 am

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@... Send Email
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...
William Tanksley, Jr
wtanksle Offline Send Email
Jan 5, 2007
4:25 pm

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...
iepos Offline Send Email Jan 16, 2007
10:23 pm

... 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...
William Tanksley, Jr
wtanksle Offline Send Email
Jan 17, 2007
5:58 am

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? ...
William Tanksley, Jr
wtanksle Offline Send Email
Jan 19, 2007
6:33 pm

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...
iepos Offline Send Email Feb 6, 2007
5:41 am

... 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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 6, 2007
7:20 pm

... i thought it might be subliminal tribute to o[kasak]i....
sa@... Send Email 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@... Send Email
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,...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 9, 2007
5:02 am

... From: "William Tanksley, Jr" <wtanksleyjr@...> To: <concatenative@yahoogroups.com> Sent: Thursday, February 08, 2007 11:54 PM Subject: Re: [stack]...
stevan apter
sa@... Send Email
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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 9, 2007
3:29 pm

... [:] ... [:] ... 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@... Send Email 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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 9, 2007
7:45 pm

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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 8, 2007
12:01 am

... 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"....
iepos Offline Send Email Feb 8, 2007
3:35 am

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...
iepos Offline Send Email Feb 9, 2007
8:35 am

... Okay; and then you posted it where? :-) Let me get my credit card. -Billy...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 9, 2007
8:09 pm

... 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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 9, 2007
6:48 pm

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@... Send Email
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...
Brent L Kerby
iepos Offline Send Email
Feb 9, 2007
10:58 pm

... 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...
Brent L Kerby
iepos Offline Send Email
Feb 10, 2007
3:31 am

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@... Send Email
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...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 11, 2007
12:27 am
 First  |  |  Next > Last 
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help