BEGIN: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Keyword |1= <code>BEGIN symbol</code> |2= Begin a new namespace. Labels and variable names will automatically be prefixed with the namespace. |3= Note that a leading dou...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
%%ii PRINTVAL {::a} | %%ii PRINTVAL {::a} | ||
%%ii END ns_1 | %%ii END ns_1 | ||
%%ii PRINTVAL(ns_1::a} | |||
This will print | This will print | ||
a=3 | a=3 | ||
::a=8 | ::a=8 | ||
ns_1::a=3 | |||
If you do not want to see the double colons in the output of [[PRINTVAL]], you need to specify <code>autoformat=true</code>. | |||
To access a symbol with attributes, e.g. <code>vec F</code> from outside of its namespace, use curly braces to separate the namespace identifier from the symbol. For example, if <code>vec F</code> resides in namespace <code>ns_1</code>, from outside of this namespace you can reference it with <code>ns_1::{vec F}</code>. | |||
|4= | |4= | ||
[[END]] | [[END]] |
Latest revision as of 17:51, 30 April 2023
Syntax
BEGIN symbol
Implemented in iMath since version 2.2.10.
Explanation
Begin a new namespace. Labels and variable names will automatically be prefixed with the namespace.
Example
Note that a leading double colon (::
) references the global (top-level) namespace.
%%ii @a@ EQDEF a=8 %%ii BEGIN ns_1 %%ii @ns_1::a@ EQDEF a=3 %%ii PRINTVAL {a} %%ii PRINTVAL {::a} %%ii END ns_1 %%ii PRINTVAL(ns_1::a}
This will print
a=3 ::a=8 ns_1::a=3
If you do not want to see the double colons in the output of PRINTVAL, you need to specify autoformat=true
.
To access a symbol with attributes, e.g. vec F
from outside of its namespace, use curly braces to separate the namespace identifier from the symbol. For example, if vec F
resides in namespace ns_1
, from outside of this namespace you can reference it with ns_1::{vec F}
.