Am So., 4. Apr. 2021 um 21:16 Uhr schrieb Jakub T. Jankiewicz < [email protected]>:
> > On Sun, Apr 4, 2021 at 4:52 AM Marc Nieper-Wißkirchen < > > [email protected]> wrote: > > > > > #lang can be used to provide a completely separate reader but in most > > > cases, it will be used to provide the default reader with a dynamically > > > extended read-table. See at the end of this page for an example in > > > Racket: < https://docs.racket-lang.org/guide/hash-reader.html>. > > > > > > > Okay, so you mean #reader rather than #lang. The trouble with #reader is > > that it is so flexible that it is not obvious how to lock it out other > than > > with a "suppress mode" that parses but returns nothing (CL > *read-suppress* > > parameter), which is a messy complication. The example of '(1 #reader > > "five.rkt"234567 8) becoming '(1 "23456" 7 8) is undelimited, and so we > > have to parse the digits but return zero values. If parsing and semantic > > processing are intertwined, this is quite difficult. > > > I thought from discussion that you don't want to allow #reader or #lang in > arbitrary place. So it works like She bang #! at the beginning of the > file. So > in other places it's just symbol, part of the symbol or syntax error. > "#lang" usually appears at the top of the file so this is what I originally had in mind. "#lang" selects (in particular) the reader to be used and I am still convinced that changing the reader halfway through is not a good idea. "#reader", on the other hand, is part of Racket's default reader and seems to be a kind of a very general reader macro. After "#reader <module-path>" has been seen, Racket passes control of the input stream to the specified "macro" until it returns with a datum. It seems that Racket throw error in this case (at least in REPL): > > (list '#lang) > > But I'm not sure if the error is correct, when using: > > (list '#lang baz) > > it try to load the language, and then complain about unexpected `)` > #lang ... in Racket seems to be parsed so that it is delimited by the end of the file. See the comment at the beginning of this page: < https://docs.racket-lang.org/guide/Module_Syntax.html>. But please be aware that I am no Racket expert.
