-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with class [wordy] #142
Comments
Getting back into bringing PL up to date now, and I like the idea of adding more extensibility to the class system, always with the proviso that the plain case remains fast and simple. Part of that is indeed documenting (and maybe rethinking) shenanigans. I like the idea of letting users decide whether they want global pollution - the trouble with this notation is that it does two things: one is give the dog a name, and the other is make the dog globally available (in some sense). I suppose for me it's like the So the revamp has started - I will look at your fork. |
Thanks for reminding me that I'm not irrelevant, Andrew! |
Ha! Don't look at my repo. I'm sure it's buggy and half-done. I don't use that anymore. I use That said, I'm not even 100% confident in my magic, although it hasn't been a problem. It's just that I wouldn't vouch for its value. And that's really the thing: value. As is, I think the class library may benefit from a depreciation and rebirth. A re-asking of the basic questions: 1: What problem does it solve? This may be too re-inventive. I may be colored by my unguided (and uninformed) attempts. I think i'm opinionating that this might be more of a conversation than an issue. |
Steve,
I keep trying to love
pl.class
, but i think it still needs some help. Of course, code beats complaining and I did code fixes for my issues. However, every time I submit a pull request, you merge it! I am really not comfortable with my work-arounds, and so no pull request until you've looked at this. However, my fork is here, if you want to look at it:https://github.com/trms/Penlight.git
[trms branch]
Insufficient documentation.
_class_init
: something that a base class does to the classes that inherits from it? Like "make fancy getter or setter" inclass.properties
?_post_init
: a base class method that is run post-_init
of the inherited class?_create
: a function that is run on the arguments received. I believe this is intended to be a sort of default argument processor?_handler
: a way to signalpl.class
that the index method was made special and needs to be inherited?Also, does all of this need to be in existence? If so, how do they work together and how don't they work together? If you're using these in
pl
, then they should be documented for use by us mortals.properties
andcatch
don't work togetherAKA #101
properties does a plain
t[k]
lookup to see if it's a simple class lookup. This triggers catch, except catch receives the class and not the table asself
. Also, it's most likely backwards of what you want, which is to do the normal thing and then catch. This is fixed in my branch. I also added_setter
to compliment_handler
. I'm having trouble conceptualizing the difference between_handler
andcatch
, btw._ENV
/_G
PollutionPutting the classes into the local _ENV makes it behave like Lua has real classes (types), but it isn't very helpful for introspection/serialization/cross-thread-shenanigans. That is, I receive a table and it has a type name. I can do
_ENV[my_type_name_field]
, but this seems unwise.In my branch, I added a
_PL_USE_GLOBALS
flag, which defaults to the current behavior. When it isfalse
it stores the classes inclass.classes
. Also,class.foo_class
returns an existing class, if it is there, instead of making a new class. If you want to remove a class, thenclass.classes.foo_class = nil
does the trick.Generally, I'd argue for more breakage of compatibility in favor of fewer legacy options. One way to do things beats two ways, especially considering that defining "one way" is one of the driving motivations for picking something like pl. As is,
pl.classes
is somewhat smelly, in that regard.I have a new slogan: "Penlight: Policies for Lua"
But, you still should follow PUC/Rio's lead and anger everyone with breaking changes, now and again.
Also, please remember that if we're not complaining, you're not relevant. ;)
The text was updated successfully, but these errors were encountered: