lua-users home
lua-l archive

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


Sorry for the followup to my own post, but I forgot to add an
important detail.

On Thu, Jul 08, 1999 at 10:39:23AM -0700, David Jeske wrote:
> I use a "parent inheritence scheme" similar to that explained in some
> older Lua documentation. This makes object methods and values chain up
> to the next parent in the chain. However, because the "nil" value is
> "not present" I can never store a nil value to override another
> value. Consider this scenerio:
> 
> -- Obj sets up my parent chaining mechanism
> 
> parent = Obj{ value = 1 }
> child = Obj{ parent = parent }
> 
> print child.value    -- yeilds 1
> 
> child.value = 2
> print child.value    -- yeilds 2
> 
> child.value = nil
> print child.value    -- yeilds 1   <<-- not what I wanted

I would be completely fine with all of this, if I could use a proper
boolean type which included real "TRUE" and "FALSE" values. In order
for me to do this, I need to be able to have all binary operators
return my real TRUE/FALSE values, and I need to have all comparison
attempts honor my FALSE as false. Unless I'm mistaken that means I
would need:

  1) an additional fallback for "equality" comparisons, which I
     would merely use as a vehicle to return TRUE/FALSE instead of
     1/nil
  2) an additional fallback for "is_true" comparisons which would
     be issued during conditionals, which I would change to honor
     my TRUE/FALSE values.

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net