|
That is illogical logic! __len adds functionality to an operator and cannot be implemented in Lua without a metamethod. The Lua Reference Manual implicitly recognises two categories of metamethods: those which provide real functionality in the core are listed in the metatable section including "__len" (and would include my proposed "__iter"). The others, implemented entirely in library code, are only mentioned in the library documentation.>>By that logic, why have a __len metamethod if we can just provide >>mytypelength(), or any of the other metamethods. :) >>-- Hisham
I agree that I'd be hard pressed to identify any of the latter that pass the Saint-Exupery test ("A designer knows that he has arrived at perfection not when there is no longer anything to add, but when there is no longer anything to take away.")
- John