New #lang modules for non-standard Scheme, old books, etc.

439 views
Skip to first unread message

Alex Gian

unread,
Jun 4, 2018, 12:48:33 PM6/4/18
to Racket Users
Hello - not totally new to Scheme,  I've done the standard working through SICP, a couple of pet projects, and also some exposure to Clojure.  What I haven't really done is delved into the language creation side of Racket, which is what I'm hoping to do next.

I have noticed that one of the impediments to teaching Scheme is that old versions of code, perhaps somewhat non-standard, perhaps a bit gung-ho in their redefining and set!-ing will not run on Racket out of the box.  I understand that this is for the greater good, to enforce modularity, etc, etc, but nevertheless it's still a problem.  It became evident to me a good while back, when I tried to show my 13-year old Scheme, via the Little Schemer, and fell flat on the first page, due to the non-standard treatment of symbols there.  It took a long while to undo the scepiticism which that gave rise to.  13-yr olds can be hard taskmasters when things don't "just work"!

As such, I think that it would be great if there was a #lang for every book out there and in this I hope to make a little contribution.  Certainly Little/Seasoned Schemer should be no-brainers, another book I saw recently by chance was "Simply Scheme" from 1998.  I read a bit thorough it and liked the approach; anyway the book must be good enough to get a plaudit from Hal Abelson when it's described as a prequel to SICP.  (It's not, IMHO, but still a very worthwhile approach, in its own right).

So I thought I'd start learning the ropes re "how everything fits together" from Simply Scheme, which provides a file called simply.scm that sets up its pedagogical environment (more than a nod to Logo there).  Of course, with redefines aplenty this thing had no chance.  So here's my first stab, which takes care of everything (I think), and was not too demanding.  I now think I understand the scoping of definitions within modules (well, a bit, anyway).  Comments, suggestions for improvement, etc, most welcome!   What I need to know now, is how can I make this file into a #lang module, so that the user can just type "#lang simply-scheme" and then get on with working through the chapters.  Any tips, links to relevant docs or tutorials, discussion sites etc, much appreciated,  the subject is not yet anywhere near as well documented as it should be (IMHO).  I have a couple more books in mind for this treatment, I think it will be interesting for the average total newcomer.

Finally, I would like my long term project to be the porting of the scmutils/mechanics code from SICM to Racket.  For me it is very telling that despite the highly vaunted "simplicity", "portability", etc. of Scheme, this flagship piece of work, from a flagship institution (MIT) and one of the biggest names from the Scheme world (Gerry Sussman) has still not found its way into the Racket ecosystem.  I believe that not only is it worthwhile in its own right, but could in fact provide the basis for an excellent embedded computer algebra system.  It can't be that difficult.  A single individual has done it for Clojure, fantastic piece of work for the JVM, anyone interested in doing something similar for Racket, feel free to say hi.

Looking forward to it all...


Matthew Butterick

unread,
Jun 4, 2018, 1:52:04 PM6/4/18
to Alex Gian, Racket Users
On Jun 4, 2018, at 9:48 AM, Alex Gian <alex...@gmail.com> wrote:

So I thought I'd start learning the ropes re "how everything fits together" from Simply Scheme, which provides a file called simply.scm that sets up its pedagogical environment (more than a nod to Logo there).  Of course, with redefines aplenty this thing had no chance.  So here's my first stab, which takes care of everything (I think), and was not too demanding.  I now think I understand the scoping of definitions within modules (well, a bit, anyway).  Comments, suggestions for improvement, etc, most welcome!   What I need to know now, is how can I make this file into a #lang module, so that the user can just type "#lang simply-scheme" and then get on with working through the chapters.  Any tips, links to relevant docs or tutorials, discussion sites etc, much appreciated,  the subject is not yet anywhere near as well documented as it should be (IMHO).  


1) Make a folder called "simply-scheme". `cd` into this directory and do `raco pkg install .`

2) Change the name of "simply_redef.scm" to "simply_redef.rkt". Add one line to the body of that file:

(provide (all-defined-out))

3) Add a "main.rkt" to the "simply-scheme" directory like so:

;;;;;;;;

#lang racket/base

(module reader syntax/module-reader
  simply-scheme)

(require simply-scheme/simply_redef)

(provide (all-from-out simply-scheme/simply_redef)
         #%module-begin #%app #%datum #%top-interaction)

;;;;;;;;


4) The language works.

#lang simply-scheme
(* 42 42)

Loading Simply Scheme...
#t
1764


These techniques are covered here:

And here:


Matthew Butterick

unread,
Jun 4, 2018, 2:31:58 PM6/4/18
to Alex Gian, Racket Users
Correction: you want to do just `raco pkg install`, not `raco pkg install .` (with a dot)

Neil Van Dyke

unread,
Jun 4, 2018, 2:45:30 PM6/4/18
to Alex Gian, Racket Users
BTW, Jens Axel Soegaard, et al. have had similar ideas about `#lang
sicp`, and the current package for doing SICP in DrRacket is at:
https://pkgs.racket-lang.org/package/sicp

FWIW, much earlier, I provided some DrRacket polish for supporting SICP,
and there might be some old code in there you like.  I discarded most of
that when Jens Axel took on the task of making better SICP support in
the current package system.  IIRC, at the time, besides a couple
SICP-specific libraries, the SICP Scheme dialect was achieved with just
some small tweaks to PLT Scheme's R5RS Language of the time, tweaking
naively, without much documentation.  For any other Scheme book
languages, you might want to look at both the current `#lang r5rs` (I
think CS books are generally pre-R6RS), and well as the current Racket
official documentation and third-party tutorials about `#lang`
implementation.  For book Schemes, I'm guessing you'll mostly run into
small differences like whether pairs&strings are mutable, whether false
and null are identical, uses of `load` that you might want to translate
to `require`, and situations in which `racket/base` provides names that
your book uses for different purposes.  One thing I considered doing for
SICP, but was too lazy, was to provide separate `#lang` or Teachpacks
for each chapter, that would provide exactly what those SICP exercises
expected (though there's an unclear balance to achieve, between being
non-discouraging, and spoon-feeding too much).
http://planet.racket-lang.org/package-source/neil/sicp.plt/1/18/planet-docs/sicp/index.html

Alex Gian

unread,
Jun 4, 2018, 3:52:31 PM6/4/18
to Racket Users
Matthew thank you very much, that's super and it all worked (with one major problem still to sort out).

Of course, I just copied it all Cargo Cult style, will sit and digest it now.

That book of yours looks very interesting!  Incidentally the link above is broken, should be 
just for anyone that wants to check out, I know I will!

One problem I had, is that the the special forms do not appear to have propagated.  They worked fine when just ran the file (beforre installing the #lang module), but they will not work after the module is set up correctly, as you showed.  I tried adding
  (only-in scheme/base  (define define) (quote quote) ...
but it didn't pick it up, I'm assuming because it's not a procedure, but a special form, but not 100% sure.  So - 

Loading Simply Scheme...
#t
> (remainder 144.0 7.0)
4
;; correct - integer return value, as it should 

;; BUT
> (define (quotrem n m)
    (list (quotient n m) (remainder n m)))
. define: unbound identifier;
 also, no #%top syntax transformer is bound in: define

;; AND, OF COURSE
> (let ((n 144.0)(m 7.0)) (list (quotient n m)(remainder n m)))
. let: unbound identifier;
 also, no #%top syntax transformer is bound in: let

;; AND ALSO
> quote
. quote: unbound identifier;
 also, no #%top syntax transformer is bound in: quote

Anyone have any idea how to sort that out?

Alex Gian

unread,
Jun 4, 2018, 3:55:09 PM6/4/18
to Racket Users
Loads of food for thought there, Neil, that's exactly the sort of feedback I'm looking for, cheers!
I'll be having a good look in due course.

Alex Gian

unread,
Jun 4, 2018, 4:08:09 PM6/4/18
to Racket Users
Incidentally, about the special forms not propagating, it's not just them, it's the whole language!
For instance, list, car, cdr et al are nowhere to be seen either.

What have I done wrong?
I want to retain the whole base language as is (that's why I specified scheme and not racket as the lang in simply_redef.rkt), EXCEPT for those functions (and macros) that I "hijack".


Daniel Prager

unread,
Jun 4, 2018, 4:13:57 PM6/4/18
to Alex Gian, Ben Greenman, Racket Users
Finally, I would like my long term project to be the porting of the scmutils/mechanics code from SICM to Racket.  For me it is very telling that despite the highly vaunted "simplicity", "portability", etc. of Scheme, this flagship piece of work, from a flagship institution (MIT) and one of the biggest names from the Scheme world (Gerry Sussman) has still not found its way into the Racket ecosystem.  I believe that not only is it worthwhile in its own right, but could in fact provide the basis for an excellent embedded computer algebra system.  It can't be that difficult.  A single individual has done it for Clojure,fantastic piece of work for the JVM, anyone interested in doing something similar for Racket, feel free to say hi.

+100

Hmmm. Let's see ...

Ben Greenman has made a #lang mechanics. (I haven't checked it out, but will need to now!)

https://github.com/bennn/mechanics

Also, here's an attractively formatted fork of SICM: https://tgvaughan.github.io/sicm/


Dan

Shu-Hung You

unread,
Jun 4, 2018, 4:31:15 PM6/4/18
to Alex Gian, Racket Users
Because (all-defined-out) finds all identifiers *defined* in the
current module and exports them. The identifiers such as `define`,
`list`, `car` etc are defined in scheme/base from the very first #lang
scheme/base line. They have to be exported explicitly:

(provide define list car #|and more|# )

It is possible to re-provide everything from scheme/base via

(provide (all-from-out scheme/base))

or provide everything except for certain identifiers:

(provide (except-out (all-from-out racket/base)
caadar
cddadr))

but I think using a positive list would be more clear.
> --
> 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.

Alex Gian

unread,
Jun 4, 2018, 4:43:42 PM6/4/18
to Racket Users
Hi Daniel - thanks for the heads-up.

Nice to see that other people have thought this way, too.
I have noticed the #lang mechanics package, but somehow I never checked it out, since I thought it was a bit skeletal, certainly incomplete and not sufficient to work twith hrough SICM.  Mr benn forgive me if I'm wrong, and please correct me, however looking through the github source there's an awful lot seems missing.

I have worked through a few chapters of SICM*, using both MIT-Scheme, and the Clojure "sicmutils", and both work just fine, although you don't have the sense of an easy-to-work-with integrated environment.  Especially if you want to create some graphics... bit Heath Robinson at best.  You sort of cry out for the Racket plot routines  ;)
* The going is slow as my physics is rusty to non-existant, but it is very rewarding to do.

If I was looking to port it right now I'd start off from the Guile or Chez ports, both reported to be working well.  Then all you'd have to do is add support for executable data structures, you know, that ( #(sin cos tan) 1.0)  =>  #(0.84 0.54 1.55)  thing.
Otherwise, for anyone really ambitious, how about a #lang MIT-Scheme, hahahahaha....  ah, portability!

Incidentally there's also Aubrey Jaffer's JACAL, nice little CAS, but not embedded, might be able to steal some stuff from it.  Colin Smith, who did the Clojure port, said that the polynomial factorisation in scmutils left a bit, erm,  to be desired.  I think we could look at modular blocks - polynomial factorization, term rewrites & logic for the symbolic differentiation (use kanren perhaps?), full graphing/plotting, ODEs, etc, and get it all working together, but embedded in standard Racket, as a library.

I believe this is what was called, back in the day the "killer application".

Alex Gian

unread,
Jun 4, 2018, 5:08:47 PM6/4/18
to Racket Users
OK, we're getting somewhere now, thanks for that clarification Dan, I can almost see where I'm going now, ha,ha.

#lang simply-scheme

(define (quotrem n m)
  (sentence n 'divided 'by m 'is (quotient n m) 'remainder (remainder n m)))
(define (acronym phrase)
  (accumulate word (every first (keep real-word? phrase))))
(define (real-word? wd)
  (not (member? wd '(a the an in of and for to with))))
(word 'com 'pu 'tah)
(quotrem 144.0 7.0)
(acronym '(the structure and interpretation of computer programs))

Gives

Welcome to DrRacket, version 6.3 [3m].
Language: simply-scheme; memory limit: 512 MB.
Loading Simply Scheme...
#t
'computah
'(144.0 divided by 7.0 is 20 remainder 4)
'sicp

Yee-hah!  Although I will have to find the most elegant way to express this.  Listing all of Schemes built-in identifiers to "provide" is not my idea of elegance.
(provide (except-out (all-from-out racket/base) ...   may be a bit better, closer to what I'm trying to say, which is "export everything, except this list of things I've hijacked."

Alex Gian

unread,
Jun 4, 2018, 5:27:01 PM6/4/18
to Racket Users

 Apologies Shu-Hung Yoo, I called you "Dan". 
I knew what I meant, though, :) it's getting a bit late... 
Shame messages can't be edited - can they?  (Sorry for the noise)

Ben Greenman

unread,
Jun 4, 2018, 5:55:13 PM6/4/18
to Alex Gian, Racket Users
> I have noticed the #lang mechanics package, but somehow I never checked it
> out, since I thought it was a bit skeletal, certainly incomplete and not
> sufficient to work twith hrough SICM.

Thats right!


My original plan with the repo was to just port the scheme code,
file-by-file. I remember having trouble checking whether the ported
code was correct.

Plan B was to work though the book and use the MIT scmutils library as
a guide when I got stuck. I haven't started trying Plan B yet.

One de-motivator for me: Racket's `math` library is excellent, and I'd
much rather contribute to it than open a new library.

Daniel Prager

unread,
Jun 4, 2018, 6:06:32 PM6/4/18
to Ben Greenman, Alex Gian, Racket Users
Might an SICM "study" group be helpful with this endeavour?

I.e. Collaboratively developing a #lang SICM *and* working through the text *and* figure out how to contribute / interface with other mathy parts of the Racket eco-system.

Dan

Alex Gian

unread,
Jun 4, 2018, 6:33:22 PM6/4/18
to Racket Users
Hi Ben, seems an awful lot of good folk hang around here!

I'd agree with you on a couple of points:
1) If Racket already has a good math library, sure, by all means use that, the streamlined choice is generally the best
2) A file-by-file translation may not be the best idea, especially since it already seems to  have been done to a great extent.

However I don't think that the many (and good) applied math routines from the mechanics package are the essence of scmutils.

For me, what little I've understood of it, the heart of the matter lies in the differentiation routines, the vector calculus if you like, going all the way up from the quasi-Einstein notation 'up' and 'down' structures, all the way to their culmination in the third part of the Sussman trilogy, "Functional Differential Geometry".  I doubt you'll find anything similar to this approach in any package, Maple might touch on it a bit, but it's proprietary and I'm not sure if it's as elegant in its core.  Spivak's books are the lodestar to scmutils, and his whole functional approach to calculus, IMHO.

Other general math routines out there may be much better, and where they are, they should be used.  I'm not interested in resurrecting the undead, LOL.  I know that the Clojure port of scmutils/mechanics used the Apache Java math libraries for solving the ODEs, and rather than having to sort out the mechanics libraries ones, and that was most probably the right thing to do.  If there's a canonical Scheme solution to a math problem it makes sense to use that.

The other cool thing about scmutils was that it was probably one of the first packages to use Automatic Differentiation, long before Deep Learning burst on the scene, and stuff like Tensorflow appeared.  It should be of interest that current work on AD is often led by Jeffrey Siskind (he of Stalin fame) and that much of the development of AD has run parallel to Scheme.  No coincidence, I daresay.

So, for me "porting" of scmutils would mean 1) generics 2) up/down structures 3) calculus and chain rule with 4) some need for symbolic differentiation too, although that does not need to be done in exactly the same way it currently is.   All the other stuff, ODEs, optimisations, simplifications etc. could be imported from wherever the best exponents of the art are.  Those are my rough thoughts anyway, thanks for providing the opportunity to air them!

Alex Gian

unread,
Jun 4, 2018, 6:42:42 PM6/4/18
to Racket Users
That's a great idea, although "SICM study group" could mean a whole lot of things.
Firstly, it could mean a physics group, only linked to scheme by prefix MIT-, since that is what works with the book NOW.  I don't think you mean that, though.
Maybe a "SICM dissection group" might be a better name for it  ;)  see where all the bits are and what can be saved, ported and what replaced or discarded.

I mean, I'd be happy to start with just a sound and complete implementation of the generics, I suspect there may be more than one way to do it!
Operators and Calculus after that.

Alex Gian

unread,
Jun 4, 2018, 7:15:31 PM6/4/18
to Racket Users
Hey!

I discovered that simply using (provide (all-from-out scheme/base)) would do exactly what i wanted!

At first I tried (provide (except-out (all-from-out racket/base) yada yada
but it would not find the identifiers that I was trying to exclude.  Then I realised that it was because I'd already aliased them.  If I really wanted to exclude them, then I'd have to do the following: (provide (except-out (all-from-out racket/base) old-* old-+ old-whatever

That was really handy discovering that, much, much neater.
Thanks again!



On Monday, June 4, 2018 at 9:31:15 PM UTC+1, Shu-Hung You wrote:

Matthias Felleisen

unread,
Jun 4, 2018, 9:23:21 PM6/4/18
to Alex Gian, Racket Users
On Jun 4, 2018, at 12:48 PM, Alex Gian <alex...@gmail.com> wrote:

 It became evident to me a good while back, when I tried to show my 13-year old Scheme, via the Little Schemer, and fell flat on the first page, due to the non-standard treatment of symbols there. 


I can’t parse your paragraph here, specifically the last couple of sentences. Do you mean that TLS’s treatment of symbols is non-standard?  TLS uses fonts to “abbreviate” things but that’s explained in the preface. Do you mean Racket’s treatment of symbols is non-standard? Well yes Racket is not Scheme. 

[[ FWIW, I do not think that TLS is a good starting point for normal 13-year olds w/o a prepared adult next to them. ]]



As such, I think that it would be great if there was a #lang for every book out there and in this I hope to make a little contribution.  Certainly Little/Seasoned Schemer should be no-brainers

A long time ago I had written a series of teaching languages for TLS (the language expands over time), but it existed only in my DrScheme (back then). I never polished it enough to release it. I’d be happy to see packages for TLS TSS and Dan’s recent extensions: http://felleisen.org/matthias/books.html


Finally, I would like my long term project to be the porting of the scmutils/mechanics code from SICM to Racket.  

AND 

On Jun 4, 2018, at 5:54 PM, Ben Greenman <benjamin...@gmail.com> wrote:

I have noticed the #lang mechanics package, but somehow I never checked it out, since I thought it was a bit skeletal, certainly incomplete and not sufficient to work twith hrough SICM.

My original plan with the repo was to just port the scheme code, file-by-file. I remember having trouble checking whether the ported code was correct.


[[ I shared this with Ben in a conversation years ago, but it is good to state in public. ]]


Around the time SICM came out, Rebecca Frankel briefly joined our lab. Initially she worked on porting SICM code to PLT Scheme on that basis. This turned out to be pretty hard because "Scheme is the least portable language in the world” (Olin Shivers, repeatedly, forever). She gave up when she realized that Gerry had exploited MIT Scheme-specific knowledge. To read the next sentence, sit down. He had mutated fields in the head of a continuation because he knew you could walk closures as lists and mutate them with set-car! in certain ways. (Her impression was this was a performance trick. I am not so sure. Years later I encountered similar tricks in AD work in a Scheme context.) 

— Matthias

Greg Hendershott

unread,
Jun 5, 2018, 12:25:23 AM6/5/18
to Matthias Felleisen, Alex Gian, Racket Users
Around the time SICM came out, Rebecca Frankel briefly joined our lab. Initially she worked on porting SICM code to PLT Scheme on that basis. This turned out to be pretty hard because "Scheme is the least portable language in the world” (Olin Shivers, repeatedly, forever). She gave up when she realized that Gerry had exploited MIT Scheme-specific knowledge. To read the next sentence, sit down. He had mutated fields in the head of a continuation because he knew you could walk closures as lists and mutate them with set-car! in certain ways. (Her impression was this was a performance trick. I am not so sure. Years later I encountered similar tricks in AD work in a Scheme context.) 

Was that this?

​<
http://groups.csail.mit.edu/mac/users/gjs/6946/sicm-html/book-Z-H-53.html#footnote_Temp_322
​>​


15
​.​
The insert procedure is ugly: 
 
(define (insert! x set cont)
  (cond ((null? set) (cont (list x) 1))
        ((< x (car set)) (cont (cons x set) 0))
        (else (let lp ((i 1) (lst set))
                (cond ((null? (cdr lst))
                       (set-cdr! lst (cons x (cdr lst)))
                       (cont set i))
                      ((< x (cadr lst))
                       (set-cdr! lst (cons x (cdr lst)))
                       (cont set i))
                      (else (lp (+ i 1) (cdr lst))))))))

Jens Axel Søgaard

unread,
Jun 5, 2018, 5:11:35 AM6/5/18
to Matthias Felleisen, Alex Gian, Racket Users
2018-06-05 3:22 GMT+02:00 Matthias Felleisen <matt...@felleisen.org>:

On Jun 4, 2018, at 12:48 PM, Alex Gian <alex...@gmail.com> wrote:

 It became evident to me a good while back, when I tried to show my 13-year old Scheme, via the Little Schemer, and fell flat on the first page, due to the non-standard treatment of symbols there. 

I can’t parse your paragraph here, specifically the last couple of sentences. Do you mean that TLS’s treatment of symbols is non-standard?  TLS uses fonts to “abbreviate” things but that’s explained in the preface. Do you mean Racket’s treatment of symbols is non-standard? Well yes Racket is not Scheme. 

It's probably due this:
    > (first 'american)
    A
See chapter 1 here:
 
    https://people.eecs.berkeley.edu/~bh/ssch1/showing.html

/Jens Axel

Neil Van Dyke

unread,
Jun 5, 2018, 9:14:55 AM6/5/18
to Racket Users
Matthias Felleisen wrote on 06/04/2018 09:22 PM:
> He had mutated fields in the head of a continuation because he knew
> you could walk closures as lists and mutate them with set-car! in
> certain ways.

I love this story.  It has a very old-school greatest-hacker-generation
folklore ring to it, from when we had fewer preconceived notions of how
things are "supposed" to work, and the ability to go in and change what
today are usually givens.

I think we should all strive to be both engineers and hackers, and be
able to draw upon both skillsets, as needed.

If I may steal coolness from another field, I'll make up an analogy with
developing the SR-71 aircraft: you draw upon top engineering knowledge
and discipline to push the limits of human capability, then you hit a
limit there, and you reach to your hacker side, and you think, "this
could work, if we were willing to leak jet fuel on the ground..."  Which
I assume would normally be considered bad engineering, which you'd be
biased to not even consider, but creativity here lets you accomplish the
otherwise impossible.

There's only so much one can do with "porting" a holistic engineering
marvel that intentionally leaked jet fuel. :)

That was close to 15 years ago?  So, if there's a new interest in this
today, we now have big advantages like faster computers with more RAM,
and a faster and more sophisticated Racket (i.e., the technology and
physics has changed), so maybe a new solution is viable.

> Years later I encountered similar tricks in AD work in a Scheme context.

Years before I learned Scheme, in an AI or robotics class, when we were
using layered abstractions atop Common Lisp, Leslie Kaelbling mentioned
this other kind of Lisp, IIRC, "Scheme", that lets you do the algorithm
backtracking a different way, with "continuations", which amazed and
hurt our brains.

When I later learned Scheme, it seemed that almost no one took advantage
of first-class continuations.  Continuations were mostly just (together
with the formal semantics) the intimidating part of an RnRS paper that
was otherwise very accessible to most programmers.

Jens Axel Søgaard

unread,
Jun 5, 2018, 9:22:28 AM6/5/18
to Alex Gian, Racket Users
2018-06-05 1:15 GMT+02:00 Alex Gian <alex...@gmail.com>:

I discovered that simply using (provide (all-from-out scheme/base)) would do exactly what i wanted!

 Note that scheme/base refers to the old PLT Scheme language, so
this is different from, say, R5RS.

/Jens Axel


Konrad Hinsen

unread,
Jun 5, 2018, 10:21:51 AM6/5/18
to Daniel Prager, Alex Gian, Racket Users
On 05/06/2018 00:06, Daniel Prager wrote:

> Might an SICM "study" group be helpful with this endeavour?
>
> I.e. Collaboratively developing a #lang SICM *and* working through the
> text *and* figure out how to contribute / interface with other mathy
> parts of the Racket eco-system.

That sounds like an interesting idea. There's a lot of good ideas in
scmutils. Getting them into the Racket universe would be great.

Konrad.

Matthias Felleisen

unread,
Jun 5, 2018, 10:30:18 AM6/5/18
to Jens Axel Søgaard, Alex Gian, Racket Users


[[ batched reply ]]
That’s SimplyScheme (SS) and I agree that it is a mismatch to good teaching.




> On Jun 5, 2018, at 12:24 AM, Greg Hendershott <greghen...@gmail.com> wrote:
>
>
> ​Was that this?
>
> ​<http://groups.csail.mit.edu/mac/users/gjs/6946/sicm-html/book-Z-H-53.html#footnote_Temp_322​>​

Possibly. When I heard about this nonsense I suggested to Rebecca to give up.





> On Jun 5, 2018, at 9:14 AM, Neil Van Dyke <ne...@neilvandyke.org> wrote:
>
> When I later learned Scheme, it seemed that almost no one took advantage of first-class continuations. Continuations were mostly just (together with the formal semantics) the intimidating part of an RnRS paper that was otherwise very accessible to most programmers.


Yes, the MIT school of Scheme never wrapped its head around continuations and friends. Neither did Common Lispers. But the Indiana school did, and it explored the idea extensively. I know because I grew up during that time. Now with hindsight we can say that continuations have their limited good use. The best thing about them is that they forced people to study PITCH (proper implementation of tail calls, plus a gratuitous H) seriously. But that’s off topic.

-— Matthias


Alex Gian

unread,
Jun 5, 2018, 12:34:09 PM6/5/18
to Racket Users
On Tuesday, June 5, 2018 at 2:23:21 AM UTC+1, Matthias Felleisen wrote:

I can’t parse your paragraph here, specifically the last couple of sentences. Do you mean that TLS’s treatment of symbols is non-standard?  TLS uses fonts to “abbreviate” things but that’s explained in the preface. Do you mean Racket’s treatment of symbols is non-standard? Well yes Racket is not Scheme. 

Yes, sorry, I'm not an academic, just an enthusiast and I can be a bit sloppy with language at times.
It was a long time ago (PLT Scheme) and though I couldn't relate exact details I do remember constantly coming up against little things, that didn't quite go as expected in the text.  Those "no answers" (Law of Cdr, Law of Eq?) when evidently there were answers was one typical example.  I thought I remembered more, but struggle to do so ATM.
What I have not forgotten is the look on the kids face: "Jeez, do you guys really put up with this kind of thing?". 
The 13yr old is an adult now, and fortunately does not hate Scheme!  

 
[[ FWIW, I do not think that TLS is a good starting point for normal 13-year olds w/o a prepared adult next to them. ]]
OK, maybe he was 14, but there were really no issues, fair bit of enthusiasm when things went as expected.  And, of course, an adult was at hand.
Personally, I don't think it's that challenging for an interested young teenager.
 

Around the time SICM came out, Rebecca Frankel briefly joined our lab. Initially she worked on porting SICM code to PLT Scheme on that basis. This turned out to be pretty hard because "Scheme is the least portable language in the world” (Olin Shivers, repeatedly, forever). She gave up when she realized that Gerry had exploited MIT Scheme-specific knowledge. To read the next sentence, sit down. He had mutated fields in the head of a continuation because he knew you could walk closures as lists and mutate them with set-car! in certain ways. (Her impression was this was a performance trick. I am not so sure. Years later I encountered similar tricks in AD work in a Scheme context.) 

I wonder what part of the code it was in.  I'd be very surprised if scmutils/mechanics does not have some real monstrosities under MIT-Scheme, but I see no reason why that would have to stay that way.  It's the concepts, I think, we're after not the weirdnesses of any particular implementation.


Alex Gian

unread,
Jun 5, 2018, 12:54:34 PM6/5/18
to Racket Users


On Tuesday, June 5, 2018 at 10:11:35 AM UTC+1, Jens Axel Søgaard wrote:

It's probably due this:
    > (first 'american)
    A
See chapter 1 here:
 
    https://people.eecs.berkeley.edu/~bh/ssch1/showing.html


Nah, that particular bit was not the sort of problem I was talking about, and anyway, as Mathias said that from Simply Scheme, not Little Schemer.
You should see how the SS given code behaves now!

    > (first 'american)
    'a
    > (first 'American)
    "A"

Ha-ha, yeah, if there's any uppercase it treats it as a string, otherwise a symbol!

However these small niggles don't bother me and I don't think they are a major pedagogical stumbling block.
They are trying to get some basic recursion and generalised-list concepts across, and a lot of the ideas seem rooted in vintage LOGO (yes, omg!). 
However as long as they get the concept across, I think these little idiosyncracies are easily forgivable.
At the end of the exercise, I think what's important for the newcomer is to have a sense, of - "Hey, I can do things with this!" rather than "Oh no, what a boring schlepp."

If we have to use a bit of "butlast" on symbols that are almost but not quite strings, it's not the end of the world, if they "get" recursion they can move away from all that. 
And pedagogically some of the clunky Logo-like stuff may be a better idea for kids than an enforced precision that brings in meaningless (to them, at this stage) baggage.

That's why I thing all the old books should have #langs, so anyone can play around, no questions asked, no judgement.  
I seems to me that the inclusive, rather than the elitist approach is what wins people over.



Alex Gian

unread,
Jun 5, 2018, 12:58:00 PM6/5/18
to Racket Users


On Tuesday, June 5, 2018 at 2:22:28 PM UTC+1, Jens Axel Søgaard wrote:

 Note that scheme/base refers to the old PLT Scheme language, so
this is different from, say, R5RS.

Thanks, I did so already, I had to pull in a whole lot of I/O stuff from r5rs, since it wasn't in scheme/base.  No problems otherwise, though.
I did get to wondering if it might be a better idea just to base the whole thing on racket/base and leapfrog all the legacy stuff, just add/adapt what's necessary.
I'm still mulling on that one.
 

Alex Gian

unread,
Jun 5, 2018, 1:08:45 PM6/5/18
to Racket Users

On Tuesday, June 5, 2018 at 3:21:51 PM UTC+1, Konrad Hinsen wrote:

That sounds like an interesting idea. There's a lot of good ideas in
scmutils. Getting them into the Racket universe would be great.

Konrad.

Sorry, I'm going to mention Clojure again for a moment.
Colin Smith has given a nice talk about SICM and porting it, here: Physics in Clojure
It's about 40 minutes long and in the first 20' he just talks about the ideas that SICM wants to bring across, especially the Lagrangian Mechanics.
But from 19:50 he talks about his experiences porting it, not just straight translating, but porting the ideas and it's really a worthwhile view.  


Alex Gian

unread,
Jun 5, 2018, 7:46:41 PM6/5/18
to Racket Users
What you have highlighted below is exactly the kind of niggling problem that these "legacy" books have, in this particular case due to the fact that many old Schemes used  to capitalise symbols in the output.  Very easily fixed, and does makes for fewer surprises for the hapless newb.

Welcome to DrRacket, version 6.3 [3m].
Language: scheme/base; memory limit: 512 MB.
Loading Simply Scheme...
All done.
> (every first '(American legacy CODE))
(A l C)
> (every butfirst '(American legacy CODE))
(merican egacy ODE)

Alex Gian

unread,
Jun 5, 2018, 8:05:15 PM6/5/18
to Racket Users
If it's OK with everyone, I'm thinking of splitting this thread, keeping this one for #lang modules to adapt dinosaur Scheme books.

Since there seems to be real live interest re #lang SICM, CAS for the Racket environment, scmutils/mechanics ports, horror stories about #lang MIT-Scheme, etc, I think that be better served in another thread.   I know I have a lot of questions in that regard and it would be confusing to mix them up with modules for TLS and the like...

====

I also invite any suggestions for legacy environments that could benefit from #lang modules.
  • Obviously, we already have Simply Scheme, since I chose it for my first experiment.
  • TLS/TSS would be great, and if any code for them is already around (even in PLT/DrScheme versions) it would be good to know.
  • I have another little-known book which I enjoyed some a good while ago (had the first explanation I ever saw about continuations) and also had some "Toolboxes" for puzzles, games, pattern matching and more, which might be still useful (or give ideas for modern versions).  It also takes credit for introducing me to the magnificent "Winning Ways for you Mathematical Plays" by Berlekamp, et al.
    The book is "Programming for Artificial Intelligence" by Kreutzer & McKenzie, you can pick it up dirt cheap, used, from the usual outlets.  It covers some Prolog and... Smalltalk too, but you can ignore those!   It would be really nice if there was some modern equivalent of this, but afaik there isn't, so there you go.
  • I know there was an XScheme once upon a time and I believe that it was put to some statistical use too.  Is it still around/relevant?
Any other suggestions for old books/environments very welcome.

Alex Gian

unread,
Jun 6, 2018, 7:13:39 AM6/6/18
to Racket Users
OK, I found a module for using Simply Scheme on Planet/dyoo.

It's very nicely done, it imports documentation into the environment, looks pro.
(require (planet dyoo/simply-scheme:2:2))

I would certainly like to be able to put packages and modules together like this and I will be looking into it.
That module does not have the correction I applied for the horrid mixing of strings and symbols in the presence of uppercase chars, it would be good to fix that.
So I would like to know, is Planet still the official repository for Racket code, and how can I contribute?

Unfortunately, the email given for the contributor dy...@cs.wpi.edu bounces, so I cannot contact him.
Is there a set procedure in place, say, like pull-requests on GitHub?



Alex Gian

unread,
Jun 6, 2018, 7:48:30 AM6/6/18
to Racket Users
PS. Found the new Racket package repository system, thanks!

--
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+unsubscribe@googlegroups.com.

Konrad Hinsen

unread,
Jun 6, 2018, 1:02:39 PM6/6/18
to racket...@googlegroups.com
On 05/06/2018 19:08, Alex Gian wrote:

> Sorry, I'm going to mention Clojure again for a moment.
> Colin Smith has given a nice talk about SICM and porting it, here:
> Physics in Clojure <https://www.youtube.com/watch?v=7PoajCqNKpg>

Thanks for the pointer, that's a nice talk indeed! And in spite of his
disclaimer of not being a physicist, he got all the physics right.

> It's about 40 minutes long and in the first 20' he just talks about the
> ideas that SICM wants to bring across, especially the Lagrangian Mechanics.
> But from 19:50 he talks about his experiences porting it, not just
> straight translating, but porting the ideas and it's really a worthwhile
> view.

I think his approach is the best one, and also what I'd suggest for a
Racket port: not just port the code, but re-express the ideas in
idiomatic Racket.

Konrad.

Matthew Butterick

unread,
Jun 6, 2018, 1:46:35 PM6/6/18
to Alex Gian, Racket Users
--
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.
Reply all
Reply to author
Forward
0 new messages