Include a file: Difference between revisions

Updated example to compile with Nim 1.4. Added text about include statement.
(Modify task for aarch64 raspberry)
(Updated example to compile with Nim 1.4. Added text about include statement.)
Line 1,754:
 
=={{header|Nim}}==
As other modular languages, in a module accessing to symbols of other modules is done by importation.<br/>
After <code>import someModule</code> an exported symbol <code>x</code> can be accessed as <code>x</code> and as <code>someModule.x</code>.
<lang nim>import someModule
import strutils except parseInt
import strutils as su, sequtils as qu # su.x works
import lib.pure.strutils, lib/pure/os, "lib/pure/times" # still strutils.x</lang>
 
But Nim provides also a way to include the content of a file, using the <code>include</code> statement:
<lang Nim>include someFile</lang>
 
The import statement is only allowed at top level whereas the include statement can be used at any level as it simply includes the text (at the appropriate indentation level). Here is an example from the Nim manual:
<lang Nim># Module A
echo "Hello World!"</lang>
<br/>
<lang Nim># Module B
proc main() =
include A
 
main() # => Hello World!</lang>
 
=={{header|OASYS Assembler}}==
Anonymous user