develooper Front page | perl.perl6.language | Postings from March 2005

Re: s/true/better name/

Thread Previous | Thread Next
From:
Luke Palmer
Date:
March 17, 2005 13:07
Subject:
Re: s/true/better name/
Message ID:
20050317210926.GA8417@navi.cx
Mark J. Reed writes:
> Luke Palmer wrote:
> 
> >Marcus Adair writes:
> >> Additionally I question whether this is truly a case improving to the
> >> point of least surprise? After all, I don't know a programmer who's
> >> going to be surprised by what true means. There are still *some* things
> >> you may have to learn in software dev 101 ;)
> >
> >The problem is this (common) one:
> >
> >    if answer() == true {
> >        # do something
> >    }
> >
> >We want to give the programmer no good way to do that, because it's
> >wrong.
> >
> 
> What do you mean "wrong"?  It looks perfectly valid to me.  It's 
> redundant, since answer() by itself would suffice as a condition with no 
> comparison, but does that make it wrong?

It's wrong in the same way that:

    if (ref $obj eq 'MyClass') {...}

Is wrong.  If answer() decides that it should start returning a more
interesting value of true, then the test fails.

Luke

Thread Previous | Thread Next


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