[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: rethinking method calls with __mcall metamethod rather than __index/__call
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 15 Jun 2009 11:29:32 +0200
On Sat, Jun 13, 2009 at 10:25 PM, David Manura<dm.lua@math2.org> wrote:
> As seen, if a set "s" has a method "union", this implies that
> s['union'] is true. For such reason, Penlight [1] avoids using the
> index operator for membership tests in its set and map ADTs.
Yes, but I had been cheerfully assuming that m[key] would return the
goods reliably - this is indeed a Big Problem. It's very natural that
set or map access is through [], but until we can control that
operation more fully, false matches are going to happen, in a nasty
silent way. And hence explicit set() & get() methods.
People from a C++ background assume that [] is overrideable, but it
ain't an operator!
steve d.