Scope/Function names and labels: Difference between revisions

Add Factor
m (Fix Perl 6 -> Raku in comments)
(Add Factor)
Line 202:
local_function() -> 2.
</lang>
 
=={{header|Factor}}==
Each word belongs to a vocabulary. Vocabularies may be added to the vocabulary search path to put their words in scope. For example, to use the <code>+</code> word:
<lang factor>USE: math
2 2 +</lang>
 
Words are visible in the vocabulary where they are defined. But only after the point where they have been defined.
<lang factor>USE: io
IN: hello-vocab
 
hello ! error; hello hasn't been defined yet
: hello ( -- ) "Hello, world!" print ;
hello ! visible here</lang>
 
This restriction can be lifted through the use of <code>DEFER:</code>.
 
<lang factor>USE: io
IN: hello-vocab
 
DEFER: hello
hello ! visible here
: hello ( -- ) "Hello, world!" print ;
hello ! visible here</lang>
 
=={{header|Go}}==
1,808

edits