<HTML><BODY><br><br><br>Mon, 28 Jul 2014 13:51:12 -0400 от "Alexander D. Knauth" <alexander@knauth.org>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br>
On Jul 28, 2014, at 11:41 AM, Roman Klochkov <<a href="/compose?To=kalimehtar@mail.ru">kalimehtar@mail.ru</a>> wrote:<br><br>
> I tried to make it with module</div></div></div></div></blockquote>.....<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br>
> (require 'm)<br>
> <br>
> Works just fine<br><br>
Yes because GENSYM was provided by ‘m, but if it’s a #lang then that doesn’t matter unless you specifically require experiment-with-hygenic-reader-extensions/lang/reader. And as I say below, I shouldn’t have to do that, and I shouldn’t have to provide GENSYM either. </div></div></div></div></blockquote>Read macros return source code. So there are no other way.<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br><br>
> I'm not very proficient with lang, but you should require module with `make-reader' to you last module.<br>
> <br>
> I installed your package via `raco pkg install git://github.com/AlexKnauth/experiment-with-hygenic-reader-extensions', but<br>
> <br>
> $ /usr/racket/bin/racket try-it.rkt<br>
> default-load-handler: cannot open module file<br>
> module path: experiment-with-hygenic-reader-extensions/lang/reader<br>
> path: /home/monk/.racket/6.0.1/pkgs/experiment-with-hygenic-reader-extensions/experiment-with-hygenic-reader-extensions/lang/reader.rkt<br>
> system error: No such file or directory; errno=2<br>
> <br>
> Maybe something wrong.<br><br>
Hmm, it doesn't do that for me. <br>
But I’m just wondering, when you look at …/pkgs/experiment-with-hygenic-reader-extensions, does it have …extensions/langreader.rkt instead of …extensions/lang/reader.rkt ? </div></div></div></div></blockquote>Yes, …extensions/langreader.rkt<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br><br>
> I think you should add (require (submod experiment-with-hygenic-reader-extensions/lang/reader reader)) to try-it. Or make another module with make-reader, which will be required by lang and result program.<br><br>
Well another good thing about hygienic macros and syntax-objects is encapsulation so that a macro can use GENSYM without having to provide GENSYM, so that GENSYM does not have visible to the user of the macro. So you shouldn’t have to add a (require experiment-…/lang/reader) to try-it.rkt.</div></div></div></div></blockquote>Yes. Because macros in Scheme/Racket don't build code, they build syntax. But read-macros build source code (in the meaning of "program text"). Don't know why, maybe because syntax context, returned by read-syntax should be current context, not the context of language definition.<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br><br>
But for some reason that’s not always working for reader extensions. <br><br>
It seems to work when the binding is from racket/base and there’s no local binding conflicting with it (but module-level bindings conflicting with it are ok), but not when it’s from a different module other than racket/base? </div></div></div></div></blockquote>It always work, when the binding is from current module (if it doesn't require racket/base, then its bindings won't work also).<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_14065698790000000618_BODY"><br><br>
I don’t know. <br><br>
> <br>
> Mon, 28 Jul 2014 11:08:20 -0400 от "Alexander D. Knauth" <<a href="/compose?To=alexander@knauth.org">alexander@knauth.org</a>>:<br>
>> Well that works fine when it’s in the same module (or namespace), but when I put it in a #lang, it breaks and I get this error:<br>
>> experiment-with-hygenic-reader-extensions/try-it.rkt:<br>
>> #lang experiment-with-hygenic-reader-extensions<br>
>> $<br>
>> ; g15667: unbound identifier in module in: g15667<br>
>> <br>
>> That’s one problem with unhygienic reader extensions. <br>
>> Since you used (datum->syntax #f ‘(GENSYM …)), it eventually took on the lexical context of try-it.rkt, where the GENSYM name isn’t there.<br>
>> <br>
>> Though strangely, if I put some lexical context on GENSYM by using (datum->syntax #f `(,#'GENSYM …)), then it gives me this error:<br>
>> experiment-with-hygenic-reader-extensions-2/try-it.rkt:<br>
>> #lang experiment-with-hygenic-reader-extensions-2<br>
>> $<br>
>> ; require: namespace mismatch;<br>
>> ; reference to a module that is not available<br>
>> ; reference phase: 0<br>
>> ; referenced module: “…/experiment-with-hygenic-reader-extensions-2/lang/reader.rkt"<br>
>> ; referenced phase level: 0 in: g24<br>
>> <br>
>> <a href="https://github.com/AlexKnauth/experiment-with-hygenic-reader-extensions" target="_blank">https://github.com/AlexKnauth/experiment-with-hygenic-reader-extensions</a><br>
>> <br><br>
> <br>
> <br>
> -- <br>
> Roman Klochkov<br><br></div></div></div></div></blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>