lua-users home
lua-l archive

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


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