Starting racket with at-exp

51 views
Skip to first unread message

Faré

unread,
Mar 2, 2020, 11:59:40 AM3/2/20
to Racket Users
How may I start a racket command-line (or emacs subprocess) with the
at-exp racket language? (or at-exp something else) The obvious
racket -l 'at-exp racket'
doesn't work.

—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
The universe isn't made of atoms, it's made of stories — Muriel Rukeyser

Stephen De Gabrielle

unread,
Mar 2, 2020, 4:24:56 PM3/2/20
to Faré, Racket Users

I tried this but had no luck; 

Miriams-MBP:~ spdegabrielle$ cat start.rkt

#lang at-exp racket/base

(require racket/format)

(displayln "try me")

(~a "foo bar") 

@~a{foo bar}


Miriams-MBP:~ spdegabrielle$ racket -t ~/start.rkt -i

Welcome to Racket v7.6.

try me

"foo bar"

"foo bar"

> (~a "foo bar")

; readline-input:1:0: #%top-interaction: unbound identifier;

;  also, no #%app syntax transformer is bound

;   at: #%top-interaction

;   in: (#%top-interaction ~a "foo bar")

; [,bt for context]

> @~a{foo bar}

  ; readline-input:2:0: #%top-interaction: unbound identifier;

;  also, no #%app syntax transformer is bound

;   at: #%top-interaction

;   in: (#%top-interaction ~a "foo bar")

; [,bt for context]



--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAN7nBXeD%3DspMKcN4Dz3zxoYJTo3vTwpVXNy6%3DHBP3e0tevaZBw%40mail.gmail.com.

Michael MacLeod

unread,
Mar 2, 2020, 5:22:36 PM3/2/20
to Stephen De Gabrielle, Faré, Racket Users
$ racket -i -l scribble/reader -e "(use-at-readtable)" -l your-lang-without-@-support

should do the trick. For example, to start a REPL in typed/racket with @-reader support, you would use:

$ racket -i -l scribble/reader -e "(use-at-readtable)" -l typed/racket
> @+[2 3]
  - : Integer [more precisely: Positive-Index]
5


Faré

unread,
Mar 2, 2020, 7:52:31 PM3/2/20
to Michael MacLeod, Stephen De Gabrielle, Racket Users
On Mon, Mar 2, 2020 at 5:22 PM Michael MacLeod
<michael...@gmail.com> wrote:
>
> $ racket -i -l scribble/reader -e "(use-at-readtable)" -l your-lang-without-@-support
>
> should do the trick.
>
Thanks. It works like a charm. But isn't a very nice recipe.
Are there reasons why -l 'at-exp racket' sdhouln't be made to work?
(Beside resource availability)

—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
The people cannot delegate to government the power to do
anything which would be unlawful for them to do themselves.
— John Locke, "A Treatise Concerning Civil Government"

Alexis King

unread,
Mar 2, 2020, 9:17:25 PM3/2/20
to Faré, Michael MacLeod, Stephen De Gabrielle, Racket Users
The -l option loads a module path. As `racket --help` documents, `-l <path>` is equivalent to `-e '(require (lib "<path>"))'`. Since (require (lib "at-exp racket")) won’t help you much, neither will `-l 'at-exp racket'`. I’m not totally sure why you thought `-l` was the right option here, but it doesn’t set the language.

It would be useful to have an option that does set the language, but it isn’t completely clear precisely what such an option ought to do. Unfortunately, the way the #lang protocol interacts with the REPL is indirect and complicated. The protocol is documented in the section of the reference entitled “Language Run-Time Configuration”: https://docs.racket-lang.org/reference/running-sa.html#%28part._configure-runtime%29

The root problem is the protocol operates on a module. A module written in a given #lang can generate a configure-runtime submodule or attach a syntax property property to its read body, but these both require a module written in the #lang already exist. The DrRacket REPL always operates in the context of some module (given in the definitions window), but the REPL run from the command line has no such luxury. Theoretically, some option could be added to generate an empty module in a specified #lang and use it to configure the REPL environment, but an empty module may not be a legal program in every #lang.

Furthermore, `at-exp racket` is not really a #lang, anyway. The #lang is just `at-exp`; the body of the module happens to start with the symbol `racket`. The `at-exp` reader reads the first symbol of its body and uses that symbol as a language path, then calls that language’s reader after installing the @-expression readtable. Again, this protocol only makes sense in the context of reading a module, and a module that starts with `#lang at-exp racket` doesn’t really have an empty body at all.
Reply all
Reply to author
Forward
0 new messages