develooper Front page | perl.fwp | Postings from December 2001

Re: tri-state flags

Thread Previous | Thread Next
Uri Guttman
December 5, 2001 23:57
Re: tri-state flags
Message ID:
>>>>> "BL" == Bart Lateur <> writes:

  BL> Yes. The values to test for are true, false (but not undef), and undef. 

i have an unusual variant of that in stem. many calls return either an
object or an error string. so the main boolean test is ref! and in some
cases undef is a legal return (usually generated by a plain return -
falling thru the end of a sub is not cool) meaning nothing was returned
but no error happened. so undef in this case is a positive result,
scalar string is a bad result and an object is the normal result. 

so here is the common test case:

	my $obj = somecall() ;
	return $obj unless ref $obj ;

error strings are always returned immediately and get propogated up the
call stack this way to be handled by the highest level call.


ps. i have skipped the golf stuff since i am at LISA and i can't get the
spare time nor easy mail access to golf. looks like a lot of fun i am

Uri Guttman  ------  --------
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About