|
Hi Steve Donovan,As for B class calling A's original method M, there isn't a general
solution which is both elegant and efficient. Assuming bee is an
object of class B, then it's bee:M(a) to call B method, A.M(bee,a) to
call A method. Any attempt to wrap this in sugar has problems (we
tried to do this for Penlight; I'd love to be proven wrong on this.)For this purpose YACI has methods cast() and super(). But I found a bug in super() from YACI.I understand what you mean.I'd like to check penlight.class also.Journeyer----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l d o t c o m
----------------------------------------2014-02-26 20:25 GMT+09:00 steve donovan <steve.j.donovan@gmail.com>:On Wed, Feb 26, 2014 at 12:48 PM, Journeyer J. JohWith dynamic languages, every value has a type at run-time [1]
<oosaprogrammer@gmail.com> wrote:
> I believe maybe you and Javier Guerra Giraldez would be right.
> I have almost no experience in such a language like lua.
With C++, we need extra notion of virtual method to ensure that
instances of classes have an associated VMT; otherwise method
dispatch is completely determined at compile time.
As for B class calling A's original method M, there isn't a general
solution which is both elegant and efficient. Assuming bee is an
object of class B, then it's bee:M(a) to call B method, A.M(bee,a) to
call A method. Any attempt to wrap this in sugar has problems (we
tried to do this for Penlight; I'd love to be proven wrong on this.)
[1] so they are not weakly-typed, just dynamically-typed; it is an
orthogonal concept. Lua tends to be more weakly-typed (using plain
tables aka "anonymous types") than Python (compulsively using
classes).