lua-users home
lua-l archive

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


Hi Steve Donovan and Javier Guerra Giraldez,

Now I am at a level that I don't understand promptly.
Maybe I replied Steve wrong. And to Javier Guerra Giraldez, I cannot reply because I need time to understand your message.

I wonder if Steve and Javier think that I am doing useless study now.
I believe OO style is nothing wrong then, what am I doing wrong now?

I am confusing...

Sincerely
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 22:52 GMT+09:00 Journeyer J. Joh <oosaprogrammer@gmail.com>:
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. Joh
<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 dynamic languages, every value has a type at run-time [1]

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).