Quick follow-up: 
It looks like I may somehow be able to change DrRacket's printing and 
reading behavior on a per-language basis somehow using the classes here 
https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style
 
but the documentation on actually doing anything with it is quite sparse (I 
only found it by searching "pretty-print-print-hook" on the DrRacket GitHub 
repo and reading backward).

My #lang currently has:
- a `main.rkt`
- a `lang/reader.rkt` using `#lang s-exp syntax/module-reader` with 
`#:read`, `#:read-syntax`, and `#:info` set.

As far as I can tell, `get-info` is never actually queried for the sorts of 
configuration which is relevant here, and the "support for #lang-based 
languages" page doesn't mention any other mechanisms for providing more 
configuration.
The "Adding module-based languages to DrRacket" begins with a paragraph 
that looks like it was chopped out of other documentation and is missing a 
bunch of context:

> For backwards compatibility, DrRacket also supports and info.rkt 
> file-based method for specifying such languages. Include these definitions: 
>
(the listed definitions all mention "drscheme"). 

The most promising paragraph is here:

> With some additional work, any language that can be compiled to Racket is 
> supported by the tools interface, not just those that use standard 
> configurations and module 
> <https://docs.racket-lang.org/reference/module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29>
> .
>
> Each language is a class that implement the drracket:language:language<%> 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3alanguage~3c~25~3e%29%29>
>  
> interface. DrRacket also provides two simpler interfaces: 
> drracket:language:module-based-language<%> 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3amodule-based-language~3c~25~3e%29%29>
>  
> and drracket:language:simple-module-based-language<%> 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3asimple-module-based-language~3c~25~3e%29%29>,
>  
> and mixin 
> <https://docs.racket-lang.org/reference/mixins.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._mixin%29%29>s
>  
> drracket:language:simple-module-based-language->module-based-language-mixin 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3asimple-module-based-language-~3emodule-based-language-mixin%29%29>
>  
> and drracket:language:module-based-language->language-mixin 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3amodule-based-language-~3elanguage-mixin%29%29>
>  
> that build implementations of drracket:language:language<%> 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3alanguage~3c~25~3e%29%29>s
>  
> from these simpler interfaces.
>
> Once you have an implementation of the drracket:language:language<%> 
> <https://docs.racket-lang.org/tools/drracket_language.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage~3alanguage~3c~25~3e%29%29>
>  
> interface, call drracket:language-configuration:add-language 
> <https://docs.racket-lang.org/tools/drracket_language-configuration.html?q=drracket%3Alanguage%3Asimple-settings-printing-style#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3alanguage-configuration~3aadd-language%29%29>
>  
> to add the language to DrRacket.
>
> Each language comes with its own type, called settings. This can be any 
> type the language designer chooses, but to aid documentation, we call it 
> settings here. The settings type is expected to contain parameters of the 
> language, such as case sensitivity, etc. The implementor of the language 
> provides a GUI so the user can configure the settings and all of the 
> language’s operations accept a setting. DrRacket maintains the current 
> settings for each language.
>

But it doesn't actually say *where* any of the relevant code is supposed to 
go.


Any guidance from someone who knows their way around these systems (as they 
relate to my queries above) would be immensely helpful (and should probably 
also just be added to the documentation pages).

On Friday, May 29, 2020 at 12:25:58 PM UTC-4, Thomas Dickerson wrote:
>
>
>
> On Friday, May 29, 2020 at 11:29:38 AM UTC-4, Matthew Flatt wrote:
>>
>> DrRacket uses `pretty-print`, which will print numbers using 
>> `number->string`, and so (I think) won't go through your parameter. 
>>
>
> This sounds like a good lead - curious if this also applies to `write` and 
> `display` as well? 
> I was having trouble with all three.
>  
>
>> I think there may be problems with parametering the core printer, 
>> partly because printing is is sometimes used where `read` is supposed 
>> to work on the result, but I think there may be other issues and I 
>> haven't thought through them enough. 
>>
>
> The intended use is in a setting where `read` has already been extended 
> (cf. my original question in this thread, which is that the DrRacket 
> interactions window appears to ignore any `read` extensions provided by a 
> #lang)
>  
>
>> Just to make sure, does using the pretty printer and its hooks 
>> (especially `pretty-print-print-hook`) work for your goals? 
>>
>
> It sounds like that may be useful for fixing this particular issue with 
> DrRacket, but I don't think it will meet my goals for the overall project.
> One question - to what extent are pretty-print-print-hooks expected to 
> cooperate with the current value of that parameter when printing compound 
> or recursive values?
> It would be great to install a hook that delegates to the existing hook 
> for everything but numbers, but that approach not working with 
> port-print-handler et al. is what led me to parameterizing over all of 
> print et al.
>
> For example, if for some reason I want numbers to be printed as Roman 
> numerals, I don't want to reimplement printing lists for `(print '(7))` to 
> result in `'(VII)`
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/b5cad591-6eba-4900-9286-89db73b652b0%40googlegroups.com.

Reply via email to