Undefined values: Difference between revisions

Add Factor
(Added Wren)
(Add Factor)
Line 301:
 
ERRE hasn't the concept of un-initialised or undefined variable: every scalar variable is allocated at runtime with value zero if numeric or value "" if string. Array type variables must be declared but follow the same initialisation rules of scalars.
 
=={{header|Factor}}==
Factor does not have undefined values. Most values used in Factor live on the data stack. They are not named, so it is not possible for them to be undefined:
<lang factor>42 . ! 42</lang>
 
Tuple slots are always initialized with <code>f</code> or other values like <code>0</code> when the slot has been class-restricted:
<lang factor>TUPLE: foo bar ;
foo new bar>> . ! f
 
TUPLE: my-tuple { n integer } ;
my-tuple new n>> . ! 0</lang>
 
Dynamic variables (and indeed all words) are initialized to <code>f</code>:
<lang factor>SYMBOL: n
n get . ! f
 
\ + get . ! f</lang>
 
Finally, Factor does not allow lexical variables to be declared without initialization:
 
<lang factor>[let
2 :> n ! There is no other way!
0 1 :> ( a b )
]</lang>
 
=={{header|Fortran}}==
1,808

edits