Discussion:
[racket] How can I dump (display) the variables defined in current the global environment
Rufus
2015-03-02 01:37:25 UTC
Permalink
I'm working through the "Little Schemer" and there are literally dozens
of variables defined in the exercises. To run code some significant
subset of these variables needs to be defined - and particular names get
reused frequently with different values.

While this is not a show stopper at the moment and I can and probably
will find a system to organize the definitions, it would be _really_
nice to be able to call a function that would display existing (already
defined) variables in the global environment with their values. And also
a function to save this state (variables in the global environment) in a
fashion that could be quickly/easily (ie one short function call) be
reloaded the next day to continue from where I left off. I have found
one full blown extension on the site that will dump the "environment"
parameters from the opsys but this is not what I'm talking about. I want
the defined variables from the global environment of the current
DrRacket session. And now I think about it, probably _all_ the
definitions for the current session sorted by type.

So. Anybody heard about something like that? I've spent some time
looking for native functions or any extensions that might serve in whole
or in part but so far, nil.

Thanks

Rufus
____________________
Racket Users list:
http://lists.racket-lang.org/users
Jordan Johnson
2015-03-02 01:54:36 UTC
Permalink
Post by Rufus
And also
a function to save this state (variables in the global environment) in a
fashion that could be quickly/easily (ie one short function call) be
reloaded the next day to continue from where I left off.
The typical workflow in DrRacket is to use the Definitions pane for this.

If I were working through TLS from scratch in DrRacket, here is how I would do it, knowing what I now know:

Start a new file when I start a new chapter.
When a definition comes up, add it to the Definitions pane, then save and click “Run”.
When a name from a previous chapter is referenced in an expression or definition, copy it in from that chapter’s file, then save and click “Run”.
When expressions are being evaluated, type the expressions in the Interactions pane.

I don’t remember if there is use of set! in TLS — that would complicate things a bit — but I don’t think there was much if any.

HTH,
jmj
Matthias Felleisen
2015-03-02 16:56:56 UTC
Permalink
This is about the best advice you can get.

I want to add that neither Racket nor the teaching languages for How to Design Programs correspond exactly to the (minimal) language of TLS. These languages are close but they differ from the language of TLS in (1) the names of the functions and (2) occasionally the assumed behavior, especially error behavior. If you are a beginner, consider using the Beginning Student Language with List Abbreviations for chapters 1 thru 7 and Intermediate plus Lambda for the remaining chapters.

You can find these languages after launching DrRacket via the -> Language -> Choose Languages menu.

-- Matthias
Post by Jordan Johnson
Post by Rufus
And also
a function to save this state (variables in the global environment) in a
fashion that could be quickly/easily (ie one short function call) be
reloaded the next day to continue from where I left off.
The typical workflow in DrRacket is to use the Definitions pane for this.
Start a new file when I start a new chapter.
When a definition comes up, add it to the Definitions pane, then save and click “Run”.
When a name from a previous chapter is referenced in an expression or definition, copy it in from that chapter’s file, then save and click “Run”.
When expressions are being evaluated, type the expressions in the Interactions pane.
I don’t remember if there is use of set! in TLS — that would complicate things a bit — but I don’t think there was much if any.
HTH,
jmj
____________________
http://lists.racket-lang.org/users
Rufus
2015-03-03 02:21:27 UTC
Permalink
Matthias
Post by Matthias Felleisen
best advice
Yes. Said as much to Jordan but my email client is schizo about replying
to the list; fixed now I think.

I did start w/the "Beginning Student Language" option in DrRacket and
after a little defining things seem to be working. But what do you mean
by "... with List Abbreviations"? I've been assuming that the more basic
language options offered are subsets of the full Racket; are there other
differences? Any potential complication/confusions w/using the complete
Racket w/libraries?

Rufus

____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-03-03 15:25:42 UTC
Permalink
The Little Lisper/Schemer uses ' (quote) for lists and that is not available in plain BSL. You need BSL-with-list-abbreviations to follow along TLS/TLL.
Post by Matthias Felleisen
Matthias
Post by Matthias Felleisen
best advice
Yes. Said as much to Jordan but my email client is schizo about replying
to the list; fixed now I think.
I did start w/the "Beginning Student Language" option in DrRacket and
after a little defining things seem to be working. But what do you mean
by "... with List Abbreviations"? I've been assuming that the more basic
language options offered are subsets of the full Racket; are there other
differences? Any potential complication/confusions w/using the complete
Racket w/libraries?
Rufus
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users

Loading...