a few questions

Ocie Mitchell — 2001-10-29 20:15:15

Hello fellow JOY users.

Hopefully there two are easy:

1) Is there a way to execute a program from the
interpreter without getting a stack printout
afterwards? If I do:

1 2 3 put newline;

I get:

3
2 1

The 3 was what I printed, but it also shows the other
stuff left on the stack.

2) Is there a way to get a list of all the symbols
defined in the current execution? help prints them
out, but doesn't give them in a list form.

3) Is there a writeup on continuations? I tried:

conts

but this causes the interpreter to segfault.

Thanks for the info,

Ocie

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Manfred von Thun — 2001-10-30 00:28:14

On Mon, 29 Oct 2001, Ocie Mitchell wrote:

> 1) Is there a way to execute a program from the
> interpreter without getting a stack printout afterwards?

Yes. There is an internal flag "autoput" which is set
by the command "setautoput". There are three possibilities:
0 setautoput (no automatic output after final .
this is the one you are after)
1 setautoput (automatic output of the top stack item only
this is the one I use most of the time)
2 setautoput (automatic output of whole stack as a list
this can be useful for debugging)

> 2) Is there a way to get a list of all the symbols
> defined in the current execution?

No, it never occurred to me to make the symbol table accessible
in this way. But it could be useful for some things I agree.
Nice thought, thanks.

> 3) Is there a writeup on continuations?

No. My various attempts to get something useful going have all failed.
It really needs an experienced Scheme programmer (and implementer)
who knows about using call-with-current-continuation, call-cc.
In the meantime I'll leave it in as a constant source of embarrassment
and as a reminder for future work. (Any volunteers?)

- Manfred

Ocie Mitchell — 2001-10-30 19:01:13

--- Manfred von Thun <phimvt@...>
wrote:
>
> On Mon, 29 Oct 2001, Ocie Mitchell wrote:
>
> > 1) Is there a way to execute a program from the
> > interpreter without getting a stack printout
> afterwards?
>
> Yes. There is an internal flag "autoput" which is
> set
> by the command "setautoput". There are three
> possibilities:
> 0 setautoput (no automatic output after
> final .
> this is the one you are
> after)
> 1 setautoput (automatic output of the top
> stack item only
> this is the one I use most
> of the time)
> 2 setautoput (automatic output of whole
> stack as a list
> this can be useful for
> debugging)
>

Aha, exactly what I was looking for.

> > 2) Is there a way to get a list of all the symbols
> > defined in the current execution?
>
> No, it never occurred to me to make the symbol table
> accessible
> in this way. But it could be useful for some things
> I agree.
> Nice thought, thanks.

I wanted to use this to write a "crashme.joy" program.
The standard crashme program creates a block of
random data and performs a longjmp into it to make
sure the OS can handle what is asked for. I thought
it might be interesting to write a program that
generates random joy quotations and then executes
them. I want this list, so that I can limit the words
to the already defined ones (otherwise, 99.999% of the
errors will be "definition needed for XXX").

>
> > 3) Is there a writeup on continuations?
>
> No. My various attempts to get something useful
> going have all failed.
> It really needs an experienced Scheme programmer
> (and implementer)
> who knows about using
> call-with-current-continuation, call-cc.
> In the meantime I'll leave it in as a constant
> source of embarrassment
> and as a reminder for future work. (Any volunteers?)

Not me :) Perhaps it should print out some sort of
warning that this is an unimplemented feature.

Ocie


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

Manfred von Thun — 2001-11-01 00:38:49

On Tue, 30 Oct 2001, Ocie Mitchell wrote:
> --- Manfred von Thun <phimvt@...>
> > On Mon, 29 Oct 2001, Ocie Mitchell wrote:
...
> > > 2) Is there a way to get a list of all the symbols
> > > defined in the current execution?
> >
> > No, it never occurred to me to make the symbol table
> > accessible in this way. But it could be useful for some things
> > I agree. Nice thought, thanks.
>
> I wanted to use this to write a "crashme.joy" program.
> The standard crashme program creates a block of
> random data and performs a longjmp into it to make
> sure the OS can handle what is asked for. I thought
> it might be interesting to write a program that
> generates random joy quotations and then executes
> them. I want this list, so that I can limit the words
> to the already defined ones (otherwise, 99.999% of the
> errors will be "definition needed for XXX").

Well, there may be more efficient ways of crashing Joy ...
but here is what you might do:
1. A crude but simple way:
a) Fire up Joy with output to a file
e.g. in Unix: joy >tempfile
b) get the online help: help.
and quit: quit.
c) edit the tempfile,
remove header and tail,
insert "[" and "]" around
the help output.
d) run joy normally: joy
prepare to get: "tempfile" include.
now read the list: get.
e) the list of defined
symbols is now on top of the stack.
Run your devil program.
2. A more elegant way:
a) run Joy normally
b) open a tempfile using John Cowan's new operators
c) write "[" to that file
d) do a help output to that file
e) write "]" to that file
f) close, now include for reading
g) get the list and run you devil program
I do not know John Cowan's file manipulation operators
well enough to be more specific.

> > > 3) Is there a writeup on continuations?
...
> > call-with-current-continuation, call-cc.
> > In the meantime I'll leave it in as a constant
> > source of embarrassment
> > and as a reminder for future work. (Any volunteers?)
>
> Not me :) Perhaps it should print out some sort of
> warning that this is an unimplemented feature.

Yes, thanks. I have added a warning to the online help for "conts".

- Manfred