(I read Writing a macro in Perl, but still need directions)
Eiffel has an implies
operator (Implicative boolean operator, see “8.5.20 Syntax: Operators” in ECMA-367, 2nd edition), i.e.
a
implies
b
meaning
not
aor
b
So the first attempt was to use
# a implies b (a --> b)
sub implies($$)
{
return !$_[0] || $_[1];
}
However that’s a function, and not an operator.
Specifically the short-cut evaluation fails for cases like
implies(defined($a), $a eq '@')
(resulting in “Use of uninitialized value $a in string eq at …“).
So the question is (for Perl 5.18.2):
Is there an elegant way to add such an “operator” to Perl?