Setting language with #lang in the REPL

后端 未结 3 1970
醉酒成梦
醉酒成梦 2021-02-04 03:48

I would like to set the language in the REPL on the fly, with #lang, not using \"-I\" command-line argument. But this gives me the error \"read: #lang not enabled i

3条回答
  •  梦毁少年i
    2021-02-04 03:55

    ; foo.rkt
    #lang whatever
    "hi"
    

    is basically the same as

    (module foo whatever
      "hi")
    

    So as a quick hack you could probably slice off the #lang line, grab the lang out of it, and stuff the rest of the buffer inside of the (module ...) form before comint-send-input-ing it.

    Even easier, if you don't mind saving the buffer to disk, first: Just send over ,enter /path/to/file.rkt to the REPL buffer, or if you're not using XREPL, (enter! "/path/to/file.rkt").

    Also, it's worth mentioning a few Racket-related modes:

    • Geiser
    • Quack
    • racket-mode (I'm guilty for this one)

    One of them might already do what you want, or, you could peek into how they work (each takes a somewhat different approach to this).

提交回复
热议问题