<div dir="ltr"><div dir="ltr"><div>Think of it as separation of runtime and compile phase.</div><div>A module may have imports and exports that are only visible at compile time; this is exactly what for-syntax import/export does.</div><div><br></div><div>for-template is a little harder to explain, you can think of it as injecting dependencies in modules who are using your module.</div><div>It is useful if you have a module that is designed to be imported for-syntax (eg macro utilities or procedural macro implementations).</div><div>If you generate code that refers to symbols not in your scope but which must be available at runtime (well, at phi-1 relative to the current phase) in the module that is importing you, then you import the relevant modules for-template and the expander does the rest.<br></div><div><br></div><div>-- vyzo<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 22, 2019 at 5:57 PM Adam <<a href="mailto:adam.mlmb@gmail.com">adam.mlmb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Ah great, thanks - it's almost fully clear now.</div><div dir="ltr"><br></div><div>|for-syntax| and |for-template|, is their motivation that |phi:| takes a set of *identifiers* - e.g. (export … (phi: +1 make-protocol-info protocol-info? …)) and hence a separate form is needed to import/export whole modules on given phi:s and that's what these are for e.g. (export … (for-syntax bigmodulename))?<br></div><div dir="ltr"><br></div></div></div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Tue, 22 Oct 2019 at 22:24, Dimitris Vyzovitis <<a href="mailto:vyzo@hackzen.org" target="_blank">vyzo@hackzen.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div dir="ltr">They are documented in the reference: <a href="https://cons.io/reference/core-prelude.html#module-sugar" target="_blank">https://cons.io/reference/core-prelude.html#module-sugar</a></div><div dir="ltr"><br></div><div>-- vyzo<br></div><br><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Tue, Oct 22, 2019 at 5:12 PM Adam <<a href="mailto:adam.mlmb@gmail.com" target="_blank">adam.mlmb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div dir="ltr">Hi Vyzo,</div><div dir="ltr"><br></div><div dir="ltr">The core prelude (<a href="https://github.com/vyzo/gerbil/blob/master/src/gerbil/prelude/core.ss" target="_blank">https://github.com/vyzo/gerbil/blob/master/src/gerbil/prelude/core.ss</a>) defines some extensions to |import| and |export|.</div><div dir="ltr"><br></div><div dir="ltr">Bumped into studying this in proto.ss, which contains (export ... (struct-out !rpc ...) ...).</div><div dir="ltr">struct-out can be understood from its use - it's for exporting a structure with its constructors, accessors, mutators. (struct-out's definition code is totally unreadable to me though.)</div><div dir="ltr"><br></div><div dir="ltr">All of these are undocumented, may you want to comment on what they are for also with a single use example (or add to some documentation section in your guide)?</div><div dir="ltr"><br></div><div dir="ltr">Thanks!<br>Adam</div><div dir="ltr"><br></div><div>defsyntax-for-import-export:s:<br></div><ul><li><div>for-syntax<br></div></li><li><div>for-template</div></li></ul><div dir="ltr"><br></div><div>defsyntax-for-import:s::<br></div><div dir="ltr"><ul><li>only-in<br></li><li>except-in<br></li><li>rename-in<br></li><li>prefix-in<br></li><li>group-in</li></ul></div><div><br></div><div>defsyntax-for-export:s:<br></div><ul><li>except-out<br></li><li>rename-out<br></li><li>prefix-out<br></li><li>struct-out<br></li></ul></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>