source: project/wiki/eggref/5/module-declarations

Last change on this file was 36801, checked in by evhan, 12 months ago

wiki/eggref: update docs/formatting/urls and eggref/5/{r7rs,fancypants,chicken-belt}

File size: 2.0 KB
Line 
1[[tags: egg]]
2
3== module-declarations
4
5[[toc:]]
6
7== Description
8
9Extends CHICKEN's [[/man/5/Declarations|declaration]] mechanism with forms for controlling modules, imports and exports.
10
11The source for this egg is available [[https://git.foldling.org/chicken-module-declarations.git|here]].
12
13=== Requirements
14
15* [[matchable]]
16
17== Usage
18
19{{module-declarations}} should be loaded as a compiler extension with the {{-extend}} (or {{-X}}) flag to {{csc}}:
20
21    $ csc -extend module-declarations <file>
22
23=== API
24
25When extended, {{module-declarations}} adds three declaration specifiers, [[#module|{{module}}]], [[#import|{{import}}]], and [[#export|{{export}}]]. These correspond to the [[/man/5/Modules|module forms]] of the same names.
26
27==== module
28
29 [declaration specifier] (module name)
30
31Wraps the current file in a [[/man/5/Modules#module|{{(module ...)}}]] form.
32
33Modules declared in this way implicitly import the {{scheme}} and {{chicken}} units before any others.
34
35If more than one {{module}} declaration is provided, the one appearing last takes precendence.
36
37==== import
38
39 [declaration specifier] (import library ...)
40
41Loads the given libraries into the current module using [[/man/5/Modules#import|{{import}}]].
42
43If no {{module}} is declared, this specifier has no effect.
44
45==== import-for-syntax
46
47 [declaration specifier] (import-for-syntax library ...)
48
49Loads the given libraries into the current module using [[/man/5/Modules#import-for-syntax|{{import-for-syntax}}]].
50
51If no {{module}} is declared, this specifier has no effect.
52
53==== export
54
55 [declaration specifier] (export identifier ...)
56
57Registers the given identifiers as exports of the current module, as with [[/man/5/Modules#export|export]].
58
59If no {{module}} is declared, this specifier has no effect.
60
61=== Example
62
63<enscript highlight="scheme">
64(declare (module alphabet-soup)
65         (import abc def ghi)
66         (export uvw xyz))
67
68; module content follows...
69</enscript>
70
71== Author
72
73[[/users/evan-hanson|Evan Hanson]]
74
75== License
76
773-Clause BSD
Note: See TracBrowser for help on using the repository browser.