jar398 / pseudoscheme

Scheme to Common Lisp
BSD 2-Clause "Simplified" License
13 stars 3 forks source link

Better Support for SBCl and CCL #2

Open BenedictHW opened 2 years ago

BenedictHW commented 2 years ago

Good Day,

I'm currently a beginner trying get started with Lisp. I've already invested hours setting up my ideal Emacs & Common Lisp environment with the copious free time only a student has. Therefore I began searching for a way to learn SICP through the Common Lisp environment. It was then Mr. Joswig on HN who pointed me towards pseudoscheme (https://news.ycombinator.com/item?id=16776704).

I decided to mark this Pull Request as a draft because I'm not entirely clear why removing '#' from the Non-constituents allows the readtable to be successfully set, and why this only occurs on SBCL. This is out of the two implementations I tested, the other being CCL. But seeing resources online as sparse as it is, I wanted to save future beginners some trouble by making this WIP PR public.

Loading pseudoscheme on SBCL v2.1.9 now does seem to work though. I ran some scheme examples I found online and pasted the results in the description of commit fba7323. I've also read online that it is most painless to use the version of scheme (R5RS?) in the textbook and not modern MIT Scheme or Racket (which can work with a compatibility module). So pseudoscheme seems to fit the bill perfectly. In fact I think some historical value would be lost if all the conditionals for ancient implementations were replaced. I think it's pretty cool code that is 16 years older than me remains a vehicle to learn the timeless concepts in SICP.

But now I've spent more time fooling around with the tooling instead of the material so I'll leave it at that.

Cheers, and thanks for pseudoscheme!

jar398 commented 2 years ago

So if I just type #t at a Common Lisp reader with the *roadblock-readtable* in effect, under your change, does that turn into the pseudoscheme true value? and similarly with other # syntaxes in scheme?

If so then I guess your fix is OK. If not it needs to be conditional on SBCL.

You probably know already that # is not a constituent character, but merely non-terminating (which is a sort of semi-constitutent status). (hyperspec) But for roadblock purposes the only thing that matters is its status as the first character of something, so making it a constituent with respect to the roadblock sounds wrong to me.

I am puzzled by the CCL changes - we're talking about Coral Common Lisp, right? Maybe CCL itself changed over the years. I never used it and must have gotten those conditionalizations from a contributor. Of course ideally all this knowledge of file extensions shouldn't reside inside Pseudoscheme itself. The underlying Lisp system obviously knows all of this and I'd expect there to be a way to query it in a modern Common Lisp. In retrospect the derived files should be foo-pso.lisp not foo.pso but remember - the file system I was using only supported 6 character file names.

Yes, this is very old code- I think mainly written around 1985, for the Symbolics Lisp Machine (which had only just implemented Common Lisp, which came out in 1984). It was never revised for ANSI Common Lisp or for ABCL. It's miraculous that it still works.

I believe the dialect implemented is R4RS, not R5RS.

Thanks for teaching me about 'draft' status PRs!

BenedictHW commented 2 years ago

Typing just #t at the Common Lisp reader with *roadblock-readtable* does work with CCL but not SBCL. The hyperspec seems mighty helpful. Yeah, I need to find a SBCL specific way to set the dispatch reader macro for '#'. Fudging about with reader macros is a bit out of my depth, so I'll shelve that thought for now and just work with CCL.

With reference to CCL, and I just learned this myself yesterday, it went roughly from

1984 - Coral Common Lisp

1988 - Macintosh Common Lisp (acquired by Apple)

2001 - OpenMCL (open sourced bits of MCL)

2007 - Clozure Common Lisp (after the entire MCL was open sourced, renamed to avoid confusion. We've come full circle!)

https://ccl.clozure.com/history.html

6 character file names? That's crazy lol. I am hoping the 'sicp.scm' included file will paper over any difference between R4RS and R5RS for my use case.

I'm pretty stubborn about getting this to work on SBCL as it happens to be the most active CL implementation in the year of our Lord 2021. If I ever persevere through the exercises, it will be my first priority to repay my debt of gratitude by 'modernizing' pseudoscheme. All the best,