rmculpepper / iracket

Jupyter kernel for Racket
BSD 3-Clause "New" or "Revised" License
95 stars 14 forks source link

Language "deinprogramm": Record definition does not work #16

Closed simons1008 closed 3 years ago

simons1008 commented 3 years ago

define-record-working.txt Hello, I am working with the language "deinprogramm" (see textbook "Schreibe dein Programm" by Mike Sperber and Herbert Klaeren). The attached code snippet works perfectly in the Editor window of DrRacket.

But in the Jupyter/iRacket environment (define-record computer make-computer ...) provokes the error message:
make-computer: unbound identifier; also, no #%top syntax transformer is bound in: make-computer

I tried the attached code snippet in the REPL window of DrRacket and got the same error message.

Do you have an explanation for this behaviour?

rmculpepper commented 3 years ago

There are some things that work inside modules (and the definitions window is actually treated as a module) but not at the REPL. Google for Racket and "the top level is hopeless", because of the difference in the order of expansion and the discovery of bound names. An IRacket notebook is essentially just a REPL, so it makes sense that your example wouldn't work there either.

You could try filing a bug report in the deinprogramm repository. It's sometimes possible to fix macros like define-record to work at the REPL by using the (define-values (name ...) (values)) trick to declare names before their definitions. I think that might be the issue in this case, but I'm not sure.

simons1008 commented 3 years ago

Thank you, that helps. I reported this to Mike Sperber. I got the response that the explanation is clear. But a change would be a somewhat bigger project. In future I will pre-test my Racket code at the DrRacket REPL before executing them in the Jupyter/iRacket environment.