lua-users home
lua-l archive

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


I agree that weak immutable tuples are a pain and quite possibly an
oxymoron.

Where they would be useful is in a caching system where one stored the
inputs to a function as a tuple. So, perhaps the answer is that a weak tuple
for which any of the elements goes away becomes equivalent to nil. That,
however, probably only makes sense within the context of a weak table and
I'm not sure what additional wrinkles that adds to the mix...

Mark

on 8/20/04 12:14 PM, Rici Lake at lua@ricilake.net wrote:

> 
> On 20-Aug-04, at 1:56 PM, Mark Hamburg wrote:
> 
>> I also think that once one uses tuples for table keys, it will become
>> necessary to address the notion of weak tuples in some way which again
>> complicates matters and makes them more not like functions.
> 
> 
> I really don't think that a weak immutable tuple has any meaning.
> 
> Consider:
> 
> function foo()
>  local myObject1, myObject2 = {}, {}
>  a = weaktuple(3, myObject1)
>  b = weaktuple(3, myObject2)
>  return a, b
> end
> 
> Now, is a == b? Depends whether garbage collection has happened or not.
> That is
> intolerable if they are used as table keys.
> 
> If tuples were mutable, this would be different, because equality would
> be defined by object identity. But weak values are counter to the
> concept of
> immutability.
>