Using DrRacket for MIT Scheme

445 views
Skip to first unread message

Yasser Hussain

unread,
Sep 30, 2018, 2:38:23 PM9/30/18
to Racket Users
I used the sicp plugin.
But I can't import modules using load command.

I remember this used to work earlier.
What's an easy way to load definitions from other scheme files? 

Neil Van Dyke

unread,
Sep 30, 2018, 3:23:26 PM9/30/18
to Yasser Hussain, Racket Users, Jens Axel Soegaard
That's probably my fault.

First, be sure you're using the `sicp` package from current Racket
package system, "https://pkgs.racket-lang.org/package/sicp", not my
older PLaneT one.

Then, Jens Axel Soegaard is still set up in GitHub, and he can add
`load` there, once he gets a chance.  But if he can't do it in time for
your needs, let me know, and I'll make a temporary replacement
"sicp/main.rkt" that you can apply to your installation of the package.

(Background: I made the original semi-polished SICP DrScheme support
package in PLaneT, which used the work of Mike Sperber and Jens Axel for
the hard parts.  While I was moving my packages from PLaneT to the
current package system, Jens Axel was in a much better position to lead
the SICP support, so we consolidated the projects, and I contributed
only a new, simpler `#lang`, rather than dump a lot of bitrotted and
no-longer-applicable stuff on the project.  Probably I neglected to add
`load` to this `#lang`, while I was slammed from triaging and moving way
too many less-important packages.  If so, I deserve any "You had ONE
job..." memes. :)

Yasser Hussain

unread,
Sep 30, 2018, 3:32:46 PM9/30/18
to Racket Users
Yeah. I was using the `sicp` package, still wasn't able to get `load` to work. :(
Can you please go ahead and make the temporary replacement so I can start working with the sicp package ? :)

Jens Axel Søgaard

unread,
Sep 30, 2018, 3:52:58 PM9/30/18
to yasserhu...@gmail.com, Racket-Users List
Den søn. 30. sep. 2018 kl. 21.32 skrev Yasser Hussain <yasserhu...@gmail.com>:
Yeah. I was using the `sicp` package, still wasn't able to get `load` to work. :(
Can you please go ahead and make the temporary replacement so I can start working with the sicp package ? :)


#lang sicp
(#%require (only racket/base load))
(load "foo.rkt")

Yasser Hussain

unread,
Sep 30, 2018, 4:02:28 PM9/30/18
to Racket Users
I tried that. It doesn't work. Says "unbound identifier..." when I try to use identifiers defined in "foo.rkt".

Jens Axel Søgaard

unread,
Sep 30, 2018, 4:05:23 PM9/30/18
to yasserhu...@gmail.com, Racket-Users List
That's because  load  only works in the repl.

Consider using require instead.



--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
--
Jens Axel Søgaard

Yasser Hussain

unread,
Sep 30, 2018, 4:11:45 PM9/30/18
to Racket Users
I tried using "#%require", still wasn't able to get it work :(
Is there a way I can get load to work as it did earlier?

Jens Axel Søgaard

unread,
Sep 30, 2018, 4:21:24 PM9/30/18
to yasserhu...@gmail.com, Racket-Users List
Use  load in the repl.

Perhaps use #lang racket or #lang r5rs instead of #lang sicp.

/Jens Axel

Yasser Hussain

unread,
Sep 30, 2018, 4:23:07 PM9/30/18
to Racket Users
Tried those, they don't work. I need to use load in the file.

Yasser Hussain

unread,
Oct 1, 2018, 5:31:09 AM10/1/18
to Racket Users
Unfortunately, I don't remember which DrRacket version, and which exact `#lang` line I was using. But I specifically remember that "load" worked with some earlier version of racket.

Problem with using `require` is that I'll have to use "#lang racket" with it, which will prevent me from using standard scheme procedures like `set-cdr!`, etc.
Is it possible for me to take a look at the source code and try to figure out why "load" doesn't work, and possible try to get it to work? Could you provide some pointers? :)

On Monday, October 1, 2018 at 12:53:26 AM UTC+5:30, Neil Van Dyke wrote:

Neil Van Dyke

unread,
Oct 1, 2018, 4:30:00 PM10/1/18
to Yasser Hussain, Racket Users
Yasser Hussain wrote on 10/1/18 5:31 AM:
> Unfortunately, I don't remember which DrRacket version, and which
> exact `#lang` line I was using. But I specifically remember that
> "load" worked with some earlier version of racket.

Hi, Yasser.  The reason I asked those questions offline was that, after
checking my original SICP PLaneT package with Racket 6.12, I was no
longer assuming that `load` ever worked with the SICP support, and
perhaps `load` wasn't necessary for the current SICP support.  I wanted
a rapid path to determining whether a regression happened, and where,
and you potentially had the best information for doing that quickly and
easily.  Then we could report back to the much broader Racket email list
with the resolution.

>
> Problem with using `require` is that I'll have to use "#lang racket"
> with it, which will prevent me from using standard scheme procedures
> like `set-cdr!`, etc.

The SICP support is only intended to be a convenience for using the very
important SICP textbook, to try maximize SICP's accessibility to
contemporary students (who might not be able to run MIT Scheme, for
whatever reason).  Please let me try to address your goals...

If you really just want to use classics like `set-cdr!` in the Racket
universe or just with Racket tools, you might like to try Racket's
`#lang r5rs`.

If you want the tons of benefits of evolved Racket, but also want
mutable pairs right now, you can have that with Racket (though, be aware
that a mutable pair isn't a subtype of pair in Racket, so all
pair/list-related code must be aware of this).  There aren't many other
non-backward-compatible differences in Racket, and the change to
mutability of pairs is the only painful one I recall, in ~18 years of
contributing to Racket,

A third possibility that I'd like to suggest is to consider trying to
write idiomatic Racket, as an exercise.  If, for example, Racket
discourages mutable pairs, try to write your code without that, and see
where it pushes you (e.g., more towards functional programming, or
strengthening your code in some ways), and then decide what you think
about that.  (Personally, I only had mutable pairs pain with the very
earliest Scheme code I wrote; in later code, I was already usually
treating pairs as immutable, and minimizing mutation in general.)

BTW, since you said "standard", I very much appreciate sentiments in
favor of standards.  Incidentally, I'm not part of the benevolent cabal;
just a bottom-tier contributor. :)  In this niche of innovative language
platforms, I suspect that Racket overall would be consistent with your
ultimate goals, even if it's in some ways not "standard" -- it's much
more than any standard, and somewhat different.  (Personally, if you're
thinking of it as a Scheme implementation, despite all their efforts to
be clear that it's not Scheme... I've probably used most of the Schemes
and descendants, and it's nice to know that I can always use other
Scheme implementation/descendants.  Probably my favorite one other than
Racket is Gambit by Marc Feeley.  I'm also fond of some of the others,
each with their own strengths, and they also remain in my pocket for
possibly using later.  I also like that I can make my own Racket `#lang`
dialect at any time, in such a way that I maintain good interoperation
with, and contribution to, the rest of the Racket world.)

> Is it possible for me to take a look at the source code and try to
> figure out why "load" doesn't work, and possible try to get it to
> work? Could you provide some pointers? :)

Yes.  Ways include:

1. To familiarize with the Racket package catalog, if you go to that
package catalog URL I gave, there's a "Code" button that, in this case,
goes to a GitHub repo, where you can do go normal Git and GitHub things.

2. Racket packages themselves actually usually include the source for
all of code+test+documentation.  (There's an even more lightweight
source-centric thing I want to do, but haven't done yet.)  I'm not sure
what's the best starting point for your needs, but here's two:
https://docs.racket-lang.org/pkg/cmdline.html
https://docs.racket-lang.org/pkg/git-workflow.html

Yasser Hussain

unread,
Oct 2, 2018, 7:22:40 AM10/2/18
to ne...@neilvandyke.org, racket...@googlegroups.com
Hey Neil,

After a digging into DrRacket a little bit, I found the solution.

If I chose language SICP (PlaneT 1.18) from the Language menu in the DrRacket IDE and remove the `lang` line from my `.scm` file, I am able to get "load" to work.

For some reason if I used the `lang` line, "#lang planet neil/sicp", "load" did not work. Shouldn't adding this lang line to my file be equivalent to selecting SICP (PlaneT 1.18) from the GUI ?

I am using the latest version of DrRacket btw.

This solves the problem, however I am curious whether there is lang line equivalent to selecting SICP (PlaneT 1.18) from the GUI?

Regards
Reply all
Reply to author
Forward
0 new messages