Scope/Function names and labels: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: phix/basics)
Line 706: Line 706:
Print Valid(M)=False
Print Valid(M)=False
</lang>
</lang>

=={{header|Nim}}==
In Nim, procedures can be defined at the module level, which is the most frequent, or in any other scope, for instance in another procedure or even in a loop or an if statement. That means that, as regards scoping, procedures are managed as variables, types, etc.

When defined at the module level, a procedure is considered private to the module. To make it visible from other modules (provided they import the whole module or only the procedure), the procedure must be annotated with an “*”.

Labels are only used when defining a block which opens a new scope: <code>block outer:</code>. This label is only used to allow breaking from the block (useful when we want to exit from internal loops): <code>break outer</code>. The label is only visible in the block.

Note that blocks are allowed anywhere where code is allowed, and so are labels. This is perfectly valid:

<lang Nim> const C = block useless: 3</lang>


=={{header|Oforth}}==
=={{header|Oforth}}==