still catching up

phimvt@lurac.latrobe.edu.au — 2000-09-14 05:20:15

Just a few comments while trying to catch up

1. In his reply to my comments - 7, Brent Kirby wrote about
implementing shunt in k/conk. It occurred to me that in Joy
there is no need for shunt - remember shunt is a useful
auxiliary for reverse.
[1 2 3] [4 5 6] shunt == [6 5 4 1 2 3]
[] [1 2 3 4] shunt == [4 3 2 1]
and hence
reverse == [] swap shunt
But equally we can use infra - the combinator which temporarily
uses the second parameter as the stack and the first parameter
as a program. It leaves behind the result stack as a list:
[10 11 12 100] [+ *] infra == [264 100]
[1 2 3] [4 5 6] infra == [6 5 4 1 2 3]
[] [1 2 3 4] infra == [4 3 2 1]
and hence
reverse == [] swap infra
This had not occurred to me before.

2. Brent also pointed out that dip can be defined:
dip == swap unit concat i
Oops, and I thought it could not be done. How embarrassing.
Thanks Brent.
Since
concat i == b
we could also uses
dip == swap unit b
Ah, well.

3. Thanks to Louis for a long discussion on Haskell. My own
knowledge of Haskell (0.01 %) is only marginally better than
my knowledge of Swahili (0.00 %). I was familiar with the
"Any" type, and that one can have lists of "Any". Am I right
that in list literals every item then has to be preceded by
"Any", thus:
[ Any 123, Any "abc", Any 'X' ]
That would make it impractical to use the Haskell reader for
reading Joy mixed lists or even programs. It is not quite
as bad in Prolog, where the only annoyance are the commas
separating the items. So a Haskell implementation of something
Joy-like will need a proper scanner and parser? Incidentally,
Lisp of course has just about the right format for lists,
if one can put up with (..) instead of [..]. I wrote a
Joy-in-Lisp once, and I should dig it out.


4. Massimo pointed out the web page for the Q-language
http://www.musikwissenschaft.uni-mainz.de/~ag/q/
I found this interesting and impressive. Some things there
could be useful in Joy.
But I should point out that of course any functional
language can be based on rewriting (for Joy, see the web-page).
In the implementation of Q (just as in the implementation of Joy),
a stack is used for efficiency. But in Q the stack is essentially
hidden from the user, whereas in Joy it is the centre.
There is a lot on the Q-pages that I should emulate.
Thanks for the hint, Massimo.

- Manfred