develooper Front page | perl.perl6.language | Postings from May 2001

Re: Separate "as" keyword? (Re: 'is' and action at a distance)

Thread Previous | Thread Next
From:
Trond Michelsen
Date:
May 18, 2001 14:29
Subject:
Re: Separate "as" keyword? (Re: 'is' and action at a distance)
Message ID:
20010518232653.A28839@crusaders.no
On Fri, May 18, 2001 at 01:34:55PM -0700, Nathan Wiger wrote:
> Dammit, I got the example exactly backwards. Try this:
>>    $Foo is true;
>>    $Foo = 0;
>>    print "Stuff" if $Foo;       # *WOULD* print - "is" assigns a
>>                                 # permanent "true" property

Sorry to jump out of lurk-mode like this, it's just that I'm trying real
hard to understand how this can be useful..

While I understand how "0 but true" is a cute hack that is destined to
be replaced by a truth property, I fail to realize how it's useful to
have a value that's true no matter what value you assign to it later.
In the case of "0 but true", you return failure with undef, but if a
function doesn't signal failure in any way - testing its return-value
isn't going to be very helpful. So, what I'm struggling the most with is
how it's useful to actually test the truth of a variable that is 
guaranteed to be true.

To me, this looks almost like an if-test like this:
foreach my $key (keys %hash) {
 next unless exists $hash{$key};
 ...
}

(ok, strictly speaking, that was an unless-test ;)

Anyway - I'm not sure how properties are supposed to work yet. Should
all properties behave in the same way, or can every propery completely
define its own behaviour?
I mean - if you can override the "truth"-property by assigning to the
variable, why shouldn't one be able to override the "constant"-property
by assigning a new value to the constant?

-- 
  // Trond Michelsen
\X/  mike@crusaders.no

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