-
Notifications
You must be signed in to change notification settings - Fork 242
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
The :catch()
method in pl.class does not pass self correctly
#307
Comments
Scratch that, the problem is related but not the same. With |
is this related to #101 ? |
I don't think I was using |
all of those are somehow related, see #79 essentially the class thing is broken beyond repair... |
I wouldn't say the class system as a whole is broken beyond repair, I use it extensively in several active projects. There are just a couple aspects of classes that don't work right and must be avoided. |
those 2 statements are equivalent; yours from a user perspective (avoid what doesn't work), mine from an owner perspective (can't possibly keep the promises made to the user) |
This almost certainly has to do with Additionally my example code above is screwing, probably because I was trying to work around one of the other class related bugs at the same time. |
Having spend almost a week of free time trying to root out bugs downstream of this problem, the only thing I have to add for now is this... Both methods, function myclass:getter (k)
print(string.format("%p"), self)
end For the first method shown above, this will be the same id shown in |
is it a single class, or does it inherit? Say you have "animal -> cat -> lion" inheritance chain.
even if My guess is you're being bitten by this, and the different "self" you get is one of the ancestors, but not the right one. This problem is what led me to: #307 (comment) edit: typo, wrong class name |
No, in this case I'm using a shallow model with no more than 1 level of inheritance. I have one base class and everything else is variants inheriting only from that one class, there are no extra levels going on. BTW I plan of fixing the depth problem because it is very restricting, but for this case I also need compatibility with old Penlight versions so I'm kind of stuck with the broken model for now. |
This fails:
This works:
Note that two arguments are getting passed an the property name to try to find is the second argument, so I would have expected the first argument to be
self
. This is not the case. Not that this contradicts the example in the documentation:If it was really the same as
__index()
thenself
should be passed through as the first argument.The text was updated successfully, but these errors were encountered: