Re: TRUE

Michael G Schwern <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
On Wed, Jan 21, 2004 at 11:09:29AM -0500, Andrew Pimlott wrote:
> I like to use symbolic constants.  Wha can remember what all those
> 1, 0, undef, and ''s mean anyway?  So I start off all my programs
> with
> 
>     use constant FALSE => !TRUE;
>     use constant TRUE => !FALSE;

You may be joking, but I used to do things like this:

	use constant TRUE  => 1==1;
	use constant FALSE => !TRUE;
	use constant SUCCESS => TRUE;
	use constant FAILURE => !SUCCESS;
	use constant ERROR => undef;

and used it like...

	sub is_foo {
		...
		return TRUE if $bleh eq 'foo';
	}

on the grounds that "return 1" is ambiguous, are you returning the number 1
or indicating truth? 

I admit its rather overdoing it a bit.  I got it from a notable bit of 
dubious advice in a book that's otherwise full of good advice, "Code 
Complete".  Their logic was that different programming languages have 
different ideas of what truth is (for some, 0 is true) and you might forget 
as you moved from one language to another.

You can still see vestiages of this in one of my earliest modules,
Tree, to the point where I toyed with having a Truth.pm.


-- 
Michael G Schwern        [email protected]  http://www.pobox.com/~schwern/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.