lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 1 Dec 1998, David Jeske wrote:

> I'm trying to put together a non-empty false value, and I can't figure
> out a way to do it. It seems to me that in order to do this I would
> need a tag method which is used for boolean comparison (as opposed to
> assignment). That way I could do:
> 
> Do any of you know an existing method for getting this kind of behavior?

You could have global true and false objects and use an "isEqual_" method
in place of "==".

true = {
    isEqual_ = function (self, o) 
	if ( self == o ) then return 1 end
	return 0
}

false = clone(true)

> I have three reasons for wanting to do this:
> 
> 1) My first motivation for this is that in proto-style "parent"
> inheritence schemes, any values which are "nil" are not-present, which
> means that accessing them requires a search of the entire inheritence
> tree, just to not find the nil value. 

how about using "Nil" instead of nil and making Nil = 0?
(Just use 0 instead off nil for false boolean values)
 
Steve