[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Concat and len metamethods are not for strings
- From: TNHarris <telliamed@...>
- Date: Tue, 5 Feb 2013 23:57:18 -0500
On Tuesday, February 05, 2013 11:08:19 PM Dirk Laurie wrote:
> You must bear in mind that most metamethods not override anything. As
> Roberto has put it, they are called when Lua does not know what to do.
> They are fallbacks in cases where Lua would just return nil, or give
> an error, or resort to something desperate like the default length
> function for tables, which is undefined except in a common but very
> special case. To get them to work for you full-time, you must go to
> considerable lengths to make sure that Lua always does not know what
> to do. Like proxy tables, for example.
This is a good answer. Metamethods are fallbacks, not overloads. It's easy to
forget that when living in the world of OOP where overloading methods is the
norm.
--
tom <telliamed@whoopdedo.org>