Node:Exporting declarations, Next:Modules, Previous:Block structure, Up:Declarations
(NOTE: WORK IN PROGRESS)
A declaration may have the form :|identifier
instead of the usual :identifier
.
The presence of a |
declares the identifier
to be exported.
If a block owns (contains) a declaration that exports a name,
the block is said to export that name.
The result of a block that exports one or more names
is a structure that binds each name to the whatever
value it gets in the block. One can later use the
notation structure'name
to extract
the bound value.
For example, the block in the parentheses here:
:B=([:|a :|b]=[100 200]; :x=10; :|c=(x+a))exports the names
a
, b
, and c
.
The block evaluates to a record with those three names.
Hence, we get that B'a=100
, B'b=200
,
and B'c=110
.
Note that the presence or absence of an exported declaration makes all the difference:
Q1> (:a=3; :b=a+1) Q2> (:a=3; :|b=a+1) [b: 4] Q3> (:|a=3; :|b=a+1) [a: 3 b: 4] Q4> (:a=3; a+1) 4 Q5> (:|a=3; a+1) # Bad! [a: 3]
Note that line 5 is poor style: None of the statements in an exporting block should evaluate to other than the null sequence. (This will probably be prohibited be some point.)
If there is an export declaration in a parameter list, the name is added to the export list of the body. (More ...)