RevBank::Symbol
Opaque symbol constants
Synopsis
use RevBank::Symbol qw(NEXT_WORD END_TURN);
return END_TURN;
if ($outcome == END_TURN) { ... }
print "unexpected $outcome"; # unexpected <END_TURN>
Description
This module will export any requested symbol, and creates them as unique global objects. They're only useful for comparing against other values, and are only equal to themselves.
They stringify to a readable representation, but you should not depend on the specific format because that may change.
The usual sentinel in Perl is a reference to a literal, such as \1, which
compares by address. Two sets of those, like the plugin return codes and the
shell's internal outcomes, can be mixed up without anyone noticing. A symbol is
only equal to itself, and comparing it to a number or a string doesn't warn.
Caveats
Names are global: two unrelated uses of the same name are the same symbol.
Symbols can only be used for equality, as a boolean, or as a string. Other uses are runtime errors.
Author
Juerd Waalboer #####@juerd.nl