develooper Front page | perl.perl5.porters | Postings from August 2008

Re: unless(...) terser than if(!...)

Thread Previous
From:
David Nicol
Date:
August 28, 2008 16:18
Subject:
Re: unless(...) terser than if(!...)
Message ID:
934f64a20808281618i10328443p8e9e107417ae0de6@mail.gmail.com
On Thu, Aug 28, 2008 at 5:56 PM, Graham Barr <gbarr@pobox.com> wrote:
>
> But they can be subtly different in the presence of overload
>
> {
>  package foo;
>  use overload "!" => sub { 1 }, "bool" => sub { 2 }, fallback => 1;
> }
>
> $a = bless [],'foo';
>
> print "a\n" if $a;
> print "b\n" if !$a;
> print "c\n" unless $a;
> print "d\n" unless !$a;

anyone for reining in overload? Probably not, it is surely useful to
create simulations where
 ( !(new Apple) ) eq "Pear"
is true.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About