It says in the FAQ (question 6.11) that logical operators simply don't
work.  Why?

As is somewhat common practice, I have set up some of my scripts to get user
info through a hash, which allows for nicely compact ways of setting
variable defaults, like:

my $yLabel = ( $opts{yLabel} or 'Amplitude');

However, since logical operators are not allowed with piddles, I can't do
something like this:

my $t = ( $opts{t} or sequence( $data->dim(0) ) );

I argue that this breaks precedence with how Perl handles this sort of
expression.  I think that any nonempty piddle should return 'true', just as
any nonempty list returns 'true' (since nonempty lists return their length
in scalar contexts).  This way, you can still set up more elaborate checks
on user passed data if you want to allow them to pass a null piddle and have
it carry some meaning:

my $t;
if ( defined ( $opts{t} )) {
$t = $opts{t};
}

Surely somebody has thought about this and justified the current lack of
logicals.  If I had to guess, it's because introducing this behavior would
lead to difficult-to-find bugs.  Is that the reasoning?  Where can I read
more?

Thanks.
David
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to