[gambit-list] Gerbil: What's the defsyntax-for-import&/export forms for, e.g. rename-in/out, except-in/out

Dimitris Vyzovitis vyzo at hackzen.org
Tue Oct 22 12:51:16 EDT 2019


Think of it as separation of runtime and compile phase.
A module may have imports and exports that are only visible at compile
time; this is exactly what for-syntax import/export does.

for-template is a little harder to explain, you can think of it as
injecting dependencies in modules who are using your module.
It is useful if you have a module that is designed to be imported
for-syntax (eg macro utilities or procedural macro implementations).
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.

-- vyzo

On Tue, Oct 22, 2019 at 5:57 PM Adam <adam.mlmb at gmail.com> wrote:

> Ah great, thanks - it's almost fully clear now.
>
> |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))?
>
>
> On Tue, 22 Oct 2019 at 22:24, Dimitris Vyzovitis <vyzo at hackzen.org> wrote:
>
>> They are documented in the reference:
>> https://cons.io/reference/core-prelude.html#module-sugar
>>
>> -- vyzo
>>
>> On Tue, Oct 22, 2019 at 5:12 PM Adam <adam.mlmb at gmail.com> wrote:
>>
>>> Hi Vyzo,
>>>
>>> The core prelude (
>>> https://github.com/vyzo/gerbil/blob/master/src/gerbil/prelude/core.ss)
>>> defines some extensions to |import| and |export|.
>>>
>>> Bumped into studying this in proto.ss, which contains (export ...
>>> (struct-out !rpc ...) ...).
>>> 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.)
>>>
>>> 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)?
>>>
>>> Thanks!
>>> Adam
>>>
>>> defsyntax-for-import-export:s:
>>>
>>>    - for-syntax
>>>    - for-template
>>>
>>>
>>> defsyntax-for-import:s::
>>>
>>>    - only-in
>>>    - except-in
>>>    - rename-in
>>>    - prefix-in
>>>    - group-in
>>>
>>>
>>> defsyntax-for-export:s:
>>>
>>>    - except-out
>>>    - rename-out
>>>    - prefix-out
>>>    - struct-out
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20191022/d1e24cf4/attachment.htm>


More information about the Gambit-list mailing list