Aaron Sherman writes:
: On Thu, 2002-02-21 at 19:49, Larry Wall wrote:
: > David M. Lloyd writes:
: > : On Thu, 21 Feb 2002, Sam Vilain wrote:
: > :
: > : > I can't count the number of times I've had to do something like:
: > : >
: > : > if (defined $foo and $foo ne "bar") { }
: > : >
: > : > to avoid my program writing garbage to STDERR.
: > :
: > : Of course you will now be able to say:
: > :
: > : if ($foo // "" ne "bar") { }
: > :
: > : Right?
: >
: > Not quite. You'd have to say:
: >
: > if ($foo // "") ne "bar" { }
: >
: > That's presuming we leave // with the same precedence as ||.
:
:
: Of course, that's not the same as the original, it just avoids the
: warning.
:
: It seems that that may have been the intent, but I'm not sure....
: Certainly this change would modify the behavior.
:
: I agree that there should be a simple way to say "I don't want to be
: told about undefined values", but I don't know what sorts of cans of
: worms that opens. Something like a property might be better:
:
: my $foo is undefined;
: if ($foo ne "bar") { .... }
:
: Such a declaration seems safer than a global, "don't warn me about it"
: directive.
Hmm, I'd have said
my $foo is defined;
to mean that.
Alternately, we could have an "I mean it" postfix operator:
if $foo! ne "bar" { ... }
On the subject of "but", however, it occurs to me that it might find a
natural place to specify runtime properties:
0 but true
@array.shift() but tainted
undef but contains(new Exception "Ouch")
That would help people distinguish value properties from variable
properties, which would still be done with C<is>.
Larry