lua-users home
lua-l archive

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




On Monday, February 24, 2014, Journeyer J. Joh <oosaprogrammer@gmail.com> wrote:
Hi Andrew Starks

Thank you for the information.
Does penligh's class library support virtual function?

It looks good but I cannot find virtual function there.

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-25 11:03 GMT+09:00 Andrew Starks <andrew.starks@trms.com>:


On Monday, February 24, 2014, Journeyer J. Joh <oosaprogrammer@gmail.com> wrote:
Hi Roland,

It was my mistake. Yes it is exactly 30 lines! And there is 30logclean.lua.
And the framework love is very interesting, there is korean page also. Very much impressive!

Thank you for providing me very useful information.

Thank you
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-25 0:33 GMT+09:00 Ousmane Roland Yonaba <roland.yonaba@gmail.com>:



On Mon, 24 Feb 2014 15:40:39, "Journeyer J. Joh" <oosaprogrammer@gmail.com> wrote:

Hi Ousmane Roland Yonaba

Thank you for good recommendation.

middleclass has so many watches, stars and forks

Let me look into it also.

And the 30log is interesting - it gives me a question why you want it to be
only 30 lines. You know it is now 31 lines ^^; one line to be removed?

I will look into those.. Thank you very much.

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



Hi Joh,

Well, it's 30 lines, as shown in Github (30 source line of code : sloc).
And well, it's not that I wanted it to be 30lines, I had to, somehow.
Part the story is written here [1], and the how-it-all-began story can be found on love2d.org forums [2].
Glad it helped, anyway.



I've been using Penlight's class library with great success. It works well, especially when you use the class.properties base class. This gives you getter and setter functions for properties. 

The nice thing is that it comes as a part of penlight, which always deserves a mention when talking about generally useful libraries. 

-Andrew

There are no other kind, if I understand correctly. 

Given that variables are not typed, there is no way to access another value as one thing or another. 

So, if you redefine a method for a derived class, objects made from the new class will always have the derived class's methods. 

You stated it nicely, earlier. There are a few concepts that do not map well to lua. 

Here, mapping virtual functions vs. an early bound method, would require explicitly calling some kind of "as" accessor method, which doesn't exist as a Penlight  feature. 

I've patched penlight a bit (I've been meaning to clean it up and post a pull request), so it's hard to remember what it does and doesn't do. 

The basics are that you can make a class and any number of derived classes from it. New classes are able to identify themselves as being derived from their base classes. You can emulate an effective, but not strict, private member property/method system by using class.properties. There isn't any concept of "friend" or other sort of nuanced access. 

Like lua, it's pragmatic and lightweight, without being overly strict or complete. That said, I sometimes eschew it for the more generic approach of either emulating objects with closures or making my own objects using meta tables.

It's pretty safe to say that a heavy duty object system is possible, but probably not worth it, in most cases. 

-Andrew