lua-users home
lua-l archive

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



On Dec 10, 2005, at 18:00, Gavin Wraith wrote:

Somebody must have asked this before! Is there anybody
who can claim to have written a Lua program that uses
a table whose keys are neither numbers nor strings,
and for which this feature is essential?

Hmmmm... not sure if it's truly "essential" as one could always devise a string representation of any tables. Nonetheless, here is an example of a "notification center" (e.g. a dispatch table) along the lines of Cocoa's NSNotificationCenter:

http://dev.alt.textdrive.com/file/lu/LUNotification.lua

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ ObjC_classic/Classes/NSNotificationCenter.html

When I first learned that Lua allowed any non-nil value
as a key, I thought "Wow - democracy for table-keys".
That was quite a time ago. But what properties do we actually
require of keys in a table? 1) that keys are distinguishable,
and sometimes 2) that keys form a linear order. Can anybody
suggest any other qualities that might be desirable?

Immutability?

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/