New addition to the file area
Nick Forde — 2002-04-15 12:48:33
As requested by Manfred I've gathered the Mandelbrot examples
discussed here into a web page:
http://groups.yahoo.com/group/concatenative/files/mandel.html
In there you can find a new variant which uses "slices" as suggested
by Louis. This is probably the slowest implementation of them all but
does allow for a very clean main loop.
Does anyone have more examples to add to this page? Perhaps there are
much faster implementation alternatives?
Ivan, you mentioned before that the example from Louis produced
garbage for you. Did you ever get to the bottom of this? I also
encountered problems under Linux. These don't appear on Solaris or
HP-UX. I'll have to investigate this some more.
Regards,
Nick.
e1_t — 2002-04-19 07:48:58
--- In concatenative@y..., Nick Forde <nickf@c...> wrote:
>
> Ivan, you mentioned before that the example from Louis produced
> garbage for you. Did you ever get to the bottom of this? I also
> encountered problems under Linux. These don't appear on Solaris or
> HP-UX. I'll have to investigate this some more.
>
Yes. The problem is not with the program but with the interpreter.
Joy needs to be compiled with the BDW garbage collector for the
programs to work correctly. At least that's the case under Linux and
Win9x/2k.
> Nick.
Ivan
Nick Forde — 2002-04-19 08:17:29
e1_t writes:
>
> Yes. The problem is not with the program but with the interpreter.
> Joy needs to be compiled with the BDW garbage collector for the
> programs to work correctly. At least that's the case under Linux and
> Win9x/2k.
This sounds like we've encountered the same problem as I too wasn't
using the BDW garbage collector. It is more than likely that the bug
is in utils.c.
Regards,
Nick.
Manfred von Thun — 2002-04-23 02:36:13
On Fri, 19 Apr 2002, Nick Forde wrote:
> e1_t writes:
> >
> > Yes. The problem is not with the program but with the interpreter.
> > Joy needs to be compiled with the BDW garbage collector for the
> > programs to work correctly. At least that's the case under Linux and
> > Win9x/2k.
>
> This sounds like we've encountered the same problem as I too wasn't
> using the BDW garbage collector.
And I thought that I was the only one who ever runs Joy without BDW.
That is not by choice but because BDW does not work for DECs VMS.
I do all my development like that. Yes, occasionally there is a
mysterious crash which I have not been able to track down. The
stack trace that one gets from VMS is normally very helpful,
but quite useless in the present case. Since this tends to
happen after several GCs in a file that tests a Joy library,
I can circumvent it by making trivial changes to that test
file - e.g. making a list a little bit longer. When all is done
I copy things to the unix machine which has the Joy pages, and
test again there, this time with BDW.
> It is more than likely that the bug
> is in utils.c.
I am not at all sure of that. When I have a program with an
absurdly large number of GCs but which does not crash, I tend to run it
again and again trying to get a crash after all, but that
normally fails. This would seem to indicate that utils.c is OK.
But those programs that do crash would tend to use different
parts of interp.c - and I think the bug may well be there.
Maybe something gets saved in an ordinary local variable (and hence
not garbage collected properly) when it should have been saved
on one of the dumps (and hence collected as required). That,
at any rate, is my conjecture.
A gold medal to anyone who can fix it.
- Manfred
John Leuner — 2002-04-23 08:18:30
> > > Yes. The problem is not with the program but with the interpreter.
> > > Joy needs to be compiled with the BDW garbage collector for the
> > > programs to work correctly. At least that's the case under Linux and
> > > Win9x/2k.
> >
> > This sounds like we've encountered the same problem as I too wasn't
> > using the BDW garbage collector.
>
> And I thought that I was the only one who ever runs Joy without BDW.
> That is not by choice but because BDW does not work for DECs VMS.
> I do all my development like that.
Er ... why?
John
Nick Forde — 2002-04-23 09:15:52
> > e1_t writes:
> > >
> > > Yes. The problem is not with the program but with the interpreter.
> > > Joy needs to be compiled with the BDW garbage collector for the
> > > programs to work correctly. At least that's the case under Linux and
> > > Win9x/2k.
OK, I've tracked down the problem. To fix this you need to update the
copy() function in utils.c:
temp->u.num = n->op == LIST_ ? (long)copy(n->u.lis) : n->u.num;
The above line needs to be replaced with:
switch(n->op) {
case INTEGER_:
temp->u.num = n->u.num; break;
case SET_:
temp->u.set = n->u.set; break;
case STRING_:
temp->u.str = n->u.str; break;
case FLOAT_:
temp->u.dbl = n->u.dbl; break;
case FILE_:
temp->u.fil = n->u.fil; break;
case LIST_:
temp->u.num = (long)copy(n->u.lis); break;
default:
temp->u.num = n->u.num;
}
The full switch isn't really essential but without it you have to make
assumptions about the Types union implementation. With the above
floating point values will now be correctly garbage collected on Linux
(NO GC_BDW). This means the mandelbrot examples will work on
Linux. I've not tested on Win2k but this should be OK as well.
Another potential problem I can see in utils.c is that inimem2() has
the line:
mem_mid = mem_low + (MEM_HIGH)/2;
This looks like it may cause problems if you read in a lot of
libraries and MEMORYMAX is low. In such a case mem_mid could be
outwith the bounds of the memory[] array. I haven't investigated the
implications of this but I suspect it wont be nice :-)
Regards,
Nick.
Nick Forde — 2002-04-23 09:32:05
I should point out that I've not been using the BDW garbage collector
because I'm running Joy on a PDA which has minimal resources. So for
me the option to not use GC_BDW is useful.
I was quite happy to switch from VMS to Unix in the '80s :-)
Regards,
Nick.
John Leuner writes:
> > > > Yes. The problem is not with the program but with the interpreter.
> > > > Joy needs to be compiled with the BDW garbage collector for the
> > > > programs to work correctly. At least that's the case under Linux and
> > > > Win9x/2k.
> > >
> > > This sounds like we've encountered the same problem as I too wasn't
> > > using the BDW garbage collector.
> >
> > And I thought that I was the only one who ever runs Joy without BDW.
> > That is not by choice but because BDW does not work for DECs VMS.
> > I do all my development like that.
>
> Er ... why?
>
> John
Nick Forde — 2002-04-23 12:44:05
Nick Forde writes:
> > > e1_t writes:
> > > > Yes. The problem is not with the program but with the interpreter.
> > > > Joy needs to be compiled with the BDW garbage collector for the
> > > > programs to work correctly. At least that's the case under Linux and
> > > > Win9x/2k.
>
> OK, I've tracked down the problem. To fix this you need to update the
> copy() function in utils.c:
> ...
Sorry, I forgot to include the test I used, I've attached it
below. The output should be the same on all platforms regardless of
whether GC_BDW is defined.
Manfred, do you have a test suite for the Joy interpreter?
Regards,
Nick.
O / O / O /
- - - - - - - - - - -X- - - - - - - - - -X - - - - - - - - -X- - - - - - - - -
O \ O \ O \
# copytest.joy - test the utils.c:copy() function by forcing GC calls.
DEFINE typelist == [1 'a {1} "1" 0.1 true [1]].
DEFINE tinylist == [] swap 1 [succ [dup [swons] dip] dip] [1 <=] repeat pop2.
DEFINE smalllist == [] swap 1 [succ [dup [swons] dip] dip] [10 <=] repeat pop2.
DEFINE biglist == [] swap 1 [succ [dup [swons] dip] dip] [100 <=] repeat pop2.
DEFINE hugelist == [] swap 1 [succ [dup [swons] dip] dip] [1000 <=] repeat pop2.
1 smalllist gc.
'a smalllist gc.
{1} smalllist gc.
"1" smalllist gc.
0.1 smalllist gc.
false smalllist gc.
[1] smalllist gc.
typelist [float] filter smalllist gc.
typelist [char] filter smalllist gc.
typelist [integer] filter smalllist gc.
typelist [string] filter smalllist gc.
typelist [set] filter smalllist gc.
typelist [logical] filter smalllist gc.
typelist [list] filter smalllist gc.
typelist [tinylist] map gc.
typelist [smalllist] map gc.
typelist [biglist] map gc.
typelist [hugelist] map gc.
quit.
John Cowan — 2002-04-23 18:35:01
Nick Forde scripsit:
> OK, I've tracked down the problem. To fix this you need to update the
> copy() function in utils.c:
>
> temp->u.num = n->op == LIST_ ? (long)copy(n->u.lis) : n->u.num;
Arrgh, I thought I had flushed all those bogons from the code.
My gratitude.
--
John Cowan <
jcowan@...>
http://www.reutershealth.com
I amar prestar aen, han mathon ne nen,
http://www.ccil.org/~cowan
han mathon ne chae, a han noston ne 'wilith. --Galadriel, _LOTR:FOTR_
Manfred von Thun — 2002-04-24 05:47:41
On Tue, 23 Apr 2002, John Leuner wrote:
[..]
> > And I thought that I was the only one who ever runs Joy without BDW.
> > That is not by choice but because BDW does not work for DECs VMS.
> > I do all my development like that.
>
> Er ... why?
When our Faculty went to Apple Macintosh 15 years ago, I refused and
stayed with what our Computer Centre had been providing: VMS on VAX.
That was very stable and - since it held all administrative files,
very well looked after. It had an adequate lot of utilities, Tex/Latex,
Teco, a proper Pascal. I stayed with it, although I have also used a
guest account for our Computer Science machines (unix). Only a couple
of years ago we started running dedicated web machines under linux,
and I put my web pages there.
- Manfred
Manfred von Thun — 2002-04-24 06:19:04
On Tue, 23 Apr 2002, Nick Forde wrote:
> > OK, I've tracked down the problem. To fix this you need to update the
> > copy() function in utils.c:
> > ...
Thank you very very much. GOLD MEDAL.
I'll wait a week or so before I modify it on the Joy page. (Just in case
there is a small change.)
I also think you are right about the other potential problem when
many libraries are read in and memorymax is small (20K at the moment).
I have already regretted having put symbol table definitions and the
Joy stack in the same big array. What you are pointing out is
another reason for keeping them separate.
[..]
> Manfred, do you have a test suite for the Joy interpreter?
On the Joy page, all those test files whose names are of the form
XXXtst.joy . They correspond to library files of the form XXXlib.joy
and exercise definitions in those libraries. (There is also one
single file lsptst.lsp which tests the lisp interpreter, but it is
called from lsptst.joy.)
That is quite a lot of test files, and some of them do torture
the garbage collector, whichever it may be. Apart from these I
do not have any further test files.
Do you think I should put your test file (below) onto the Joy page?
- Manfred
> - - - - - - - - - - -X- - - - - - - - - -X - - - - - - - - -X- - - - - - - - -
> O \ O \ O \
>
> # copytest.joy - test the utils.c:copy() function by forcing GC calls.
>
> DEFINE typelist == [1 'a {1} "1" 0.1 true [1]].
>
> DEFINE tinylist == [] swap 1 [succ [dup [swons] dip] dip] [1 <=] repeat pop2.
> DEFINE smalllist == [] swap 1 [succ [dup [swons] dip] dip] [10 <=] repeat pop2.
> DEFINE biglist == [] swap 1 [succ [dup [swons] dip] dip] [100 <=] repeat pop2.
> DEFINE hugelist == [] swap 1 [succ [dup [swons] dip] dip] [1000 <=] repeat pop2.
>
> 1 smalllist gc.
> 'a smalllist gc.
> {1} smalllist gc.
> "1" smalllist gc.
> 0.1 smalllist gc.
> false smalllist gc.
> [1] smalllist gc.
>
> typelist [float] filter smalllist gc.
> typelist [char] filter smalllist gc.
> typelist [integer] filter smalllist gc.
> typelist [string] filter smalllist gc.
> typelist [set] filter smalllist gc.
> typelist [logical] filter smalllist gc.
> typelist [list] filter smalllist gc.
>
> typelist [tinylist] map gc.
> typelist [smalllist] map gc.
> typelist [biglist] map gc.
> typelist [hugelist] map gc.
>
> quit.
>
>
>
> To unsubscribe from this group, send an email to:
> concatenative-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Louis Madon — 2002-04-24 08:12:04
Hi Manfred,
In your paper, the Algebra of Joy, you give a number of examples like:
swap swap == id
succ pred == id
dup and == id
cons uncons == id
0 + == id
and many more like that.
While I understand the intent of these, it seems to me they must be
using a different interpretation of == than is normally the case.
Normally, I would assume that if P == Q then P and Q are identical and
may be substituted for each other in any context.
However, in all of the above examples, substitution is only valid in one
direction.
Consider: 1 id => 1
But: 1 swap swap => error
So what to make of the statement 'swap swap == id'?
Louis.
Nick Forde — 2002-04-24 09:00:59
Manfred von Thun writes:
>
> Do you think I should put your test file (below) onto the Joy page?
>
No. I was just curious if there were some other tests I was missing.
Regards,
Nick.
John Carter — 2002-04-26 02:39:38
On Wed, 24 Apr 2002, Louis Madon wrote:
> But: 1 swap swap => error
>
> So what to make of the statement 'swap swap == id'?
Hmm. There are a number of "inconveniences" like that. Perhaps it would
make Joy easier to work with algebraically if it was defined to start with
an infinite stack of nulls.
Sort of like the Fermi sea of Quantum Electro Dynamics.
In terms of the joy interpreter it would just generated them as needed.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email :
john.carter@...
New Zealand
May contain traces of nuts. This email was packed by mass, not
volume. Contents may have settled during distribution.
This email is not designed or intended for use in on-line control of
aircraft, air traffic, aircraft navigation or aircraft communications; or in
the design, construction, operation or maintenance of any nuclear
facility. Reader represents and warrants that it will not use or
redistribute the email for such purposes.
Louis Madon — 2002-04-26 03:14:58
On Friday, April 26, 2002, at 12:39 PM, John Carter wrote:
> On Wed, 24 Apr 2002, Louis Madon wrote:
>
> > But: 1 swap swap => error
> >
> > So what to make of the statement 'swap swap == id'?
>
> Hmm. There are a number of "inconveniences" like that.
It would be nice to do up a list of them. Not that I'm trying to be
picky, but I think it leads to a better understanding of the language.
> Perhaps it would
> make Joy easier to work with algebraically if it was defined to start
> with
> an infinite stack of nulls.
That would probably fix 'swap swap == id' but how about 'cons uncons ==
id' - would null be defined as a valid value to any function?
And then consider a substitution like '"hello" id ==> "hello" succ
pred' - still an error I think.
It might be easier to just have a new symbol, say '<=' instead of '==',
such that for P <= Q we're saying that P is a special case of Q - it has
the same function but is only defined over a smaller domain. Therefore
Q can always be substituted for P but not vice versa.
Louis.
[Non-text portions of this message have been removed]
Manfred von Thun — 2002-04-26 03:25:47
On Wed, 24 Apr 2002, Louis Madon wrote:
> Hi Manfred,
>
> In your paper, the Algebra of Joy, you give a number of examples like:
> swap swap == id
[..]
> While I understand the intent of these, it seems to me they must be
> using a different interpretation of == than is normally the case.
Thank you, yes. You have correctly put your finger on something that
has bothered me ever since I wrote it (and, to my shame, never did
anything about it). There are two important relations to consider:
1. A rather weak one, which I'll write as P =equiv= Q ,
to mean:
on all argument stacks for which both P and Q are defined,
the value stacks computed by programs P and Q are identical
or more compactly:
in the intersection of their domains, P and Q are identical.
2. A stronger one (the "proper" one), writen as P =ident= Q,
to mean:
the functions computed by programs P and Q are defined
on the same arguments and produce the same values.
or compactly:
the functions P and Q are identical.
As you correctly point out, I vascillate between (1) and (2).
The relation =ident= is reflexive, symmetric and transitive,
i.e. it is an equivalence relation, and it is also substitutive
in extensional contexts. By contrast, =equiv= is only reflexive
and symmetric, it is not even transitive.
We do have:
For all programs P and Q,
IF P =ident= Q THEN P =equiv= Q
> Normally, I would assume that if P == Q then P and Q are identical and
> may be substituted for each other in any context.
[..]
> So what to make of the statement 'swap swap == id'?
Indeed. We have:
a. swap swap =ident= id is false
b. swap swap =equiv= id is true
c. swap swap swap =ident= swap is true
d. swap swap swap =equiv= swap is true
and similarly for "not" instead of "swap". And so on.
It is clear that I shall have to go through the algebra with
some more care. Thank you.
- Manfred
Brent Kerby — 2002-04-26 05:08:23
> It might be easier to just have a new symbol, say '<=' instead of '==',
> such that for P <= Q we're saying that P is a special case of Q - it has
> the same function but is only defined over a smaller domain. Therefore
> Q can always be substituted for P but not vice versa.
I think this is a cool idea. But to say that P is a special case of Q, do
you think it might be better to write "P => Q" (the arrow going the opposite
way)? That way would seem to more clearly suggest that "P" can be rewritten
as "Q" but not vice versa. You could then read "=>" as either "is a special
case of" or "reduces to". For example,
swap swap => id
could say that "swap swap" is a special case of "id", or in other words that
"swap swap" can be replaced by "id".
This is really an unimportant syntax matter, I guess ...
> Louis.
- Brent
Louis Madon — 2002-04-26 04:33:17
On Friday, April 26, 2002, at 01:25 PM, Manfred von Thun wrote:
...
> There are two important relations to consider:
> 1. A rather weak one, which I'll write as P =equiv= Q ,
> to mean:
> on all argument stacks for which both P and Q are defined,
> the value stacks computed by programs P and Q are identical
> or more compactly:
> in the intersection of their domains, P and Q are identical.
> 2. A stronger one (the "proper" one), writen as P =ident= Q,
> to mean:
> the functions computed by programs P and Q are defined
> on the same arguments and produce the same values.
> or compactly:
> the functions P and Q are identical.
>
> As you correctly point out, I vascillate between (1) and (2).
>
> The relation =ident= is reflexive, symmetric and transitive,
> i.e. it is an equivalence relation, and it is also substitutive
> in extensional contexts. By contrast, =equiv= is only reflexive
> and symmetric, it is not even transitive.
Ah, I hadn't thought of something like =equiv=. What I was thinking of
is a slightly stronger relation: P <= Q to indicate P =equiv= Q with the
added condition that P's domain must be less than or equal to Q's. This
relation is both reflexive and transitive but antisymmetric rather than
symmetric (ie. a partial order rather than an equivalence relation).
It would be interesting to know if there are some instances where
theorems really must be stated using the weaker =equiv= relation.
BTW, also in the algebra of joy paper, these don't make sense to me:
false or == pop false
true and == pop true
maybe you meant:
false and == pop false
true or == pop true
?
Louis.
[Non-text portions of this message have been removed]
Louis Madon — 2002-04-26 04:36:22
On Friday, April 26, 2002, at 03:08 PM, Brent Kerby wrote:
> ... But to say that P is a special case of Q, do
> you think it might be better to write "P => Q" (the arrow going the
> opposite
> way)? That way would seem to more clearly suggest that "P" can be
> rewritten
> as "Q" but not vice versa. You could then read "=>" as either "is a
> special
> case of" or "reduces to". For example,
>
> swap swap => id
>
> could say that "swap swap" is a special case of "id", or in other words
> that
> "swap swap" can be replaced by "id".
>
> This is really an unimportant syntax matter, I guess ...
I personally don't mind, I'd be happy with => too. I was thinking of
the fact that P has a smaller domain than Q which I was I wrote it
as <=. I guess we should leave it to Manfred to pick an official
symbol ...
Louis.
[Non-text portions of this message have been removed]
John Carter — 2002-04-26 06:29:22
On Fri, 26 Apr 2002, Louis Madon wrote:
> That would probably fix 'swap swap == id' but how about 'cons uncons ==
> id' - would null be defined as a valid value to any function?
> And then consider a substitution like '"hello" id ==> "hello" succ
> pred' - still an error I think.
As usual Manfred has the correct solution.
Sigh, I'm reluctant to give up on my Fermi Sea of Nulls.
But I can't see how to make it work.
Oh dear.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email :
john.carter@...
New Zealand
May contain traces of nuts. This email was packed by mass, not
volume. Contents may have settled during distribution.
This email is not designed or intended for use in on-line control of
aircraft, air traffic, aircraft navigation or aircraft communications; or in
the design, construction, operation or maintenance of any nuclear
facility. Reader represents and warrants that it will not use or
redistribute the email for such purposes.
Manfred von Thun — 2002-04-29 04:47:18
On Fri, 26 Apr 2002, Louis Madon wrote:
> On Friday, April 26, 2002, at 01:25 PM, Manfred von Thun wrote:
> ...
> > There are two important relations to consider:
> > 1. A rather weak one, which I'll write as P =equiv= Q ,
> > to mean:
> > on all argument stacks for which both P and Q are defined,
> > the value stacks computed by programs P and Q are identical
[..]
> Ah, I hadn't thought of something like =equiv=. What I was thinking of
> is a slightly stronger relation: P <= Q to indicate P =equiv= Q with the
> added condition that P's domain must be less than or equal to Q's. This
> relation is both reflexive and transitive but antisymmetric rather than
> symmetric (ie. a partial order rather than an equivalence relation).
I think you are right, your relation is more useful.
As to the notation, this is a consideration: functions (in extension)
are just relations, which are sets of n-tuples (with some restrictions).
At any rate, functions are sets. (I know that category theorist would
not agree with that, but let's proceed...) If Q is defined wherever
P is defined, and both give the same value where P is defined, then
the set (of n-tuples) P is a subset of the set (of n-tuples) Q.
So something like the subset notation would suggest itself, except
that we need something that works in plain ol' Ascii. Your <= is
just about right, I think, except that it is the same symbol as
the numeric "less than or equal" symbol. So I would suggest <==
with the long shaft, reminiscent of == for real function identity.
I shall have to go through the algebra paper and a few smaller bits
elsewhere, but it will have to wait.
> It would be interesting to know if there are some instances where
> theorems really must be stated using the weaker =equiv= relation.
Writing a two-headed arrow with a long shaft, this is a candidate:
swap swap pop <==> succ pop
> BTW, also in the algebra of joy paper, these don't make sense to me:
>
> false or == pop false
> true and == pop true
>
> maybe you meant:
>
> false and == pop false
> true or == pop true
Oops, yes.
(You would never believe that I actually teach this sort of thing.)
Fixed.
Thanks again for both.
- Manfred
Manfred von Thun — 2002-04-29 07:38:56
On Wed, 24 Apr 2002, Manfred von Thun wrote:
> On Tue, 23 Apr 2002, Nick Forde wrote:
>
> > > OK, I've tracked down the problem. To fix this you need to update the
> > > copy() function in utils.c:
> > > ...
>
> Thank you very very much. GOLD MEDAL.
I've done the update to utils.c on the Joy page.
- Manfred
Manfred von Thun — 2002-05-13 01:42:23
I have added a new library on the main Joy page. It deals with
context-free grammars (and hence also with regular expressions).
There are two possible uses of grammars explored in the test
programs:
1. Reading a grammar and generating all strings in the language
(Since many languages are infinite, there has to be a limit
to the output that is actually shown.)
2. Reading a grammar and testing whether a particular given
string is in the language.
In future this library might be extended with further capabilities
having to do with grammars. The demos are quite extensive, and
they show the various possible styles of output for both 1. amd 2.
The two central programs use backtracking extensively, so this
library and the preceding one on propositional logic use very
similar techniques.
Main Joy page:
http://www.latrobe.edu.au/philosophy/phimvt/joy.html
Grammar library:
http://www.latrobe.edu.au/philosophy/phimvt/joy/grmlib.joy
Demo tests and output:
http://www.latrobe.edu.au/philosophy/phimvt/joy/grmtst.joy
http://www.latrobe.edu.au/philosophy/phimvt/joy/grmtst.out
My next project will be to update the manual - that is long overdue.
I am going away by the end of the week on an extended holiday,
and I won't be back until early July. I don't yet know what
kind of computer access I'll have, if any. So don't be offended
if you don't hear from me at all.
- Manfred