-
Notifications
You must be signed in to change notification settings - Fork 240
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
class() calls constructor of previously created class #9
Comments
Yeah, I see exactly what you mean - it's a sneaky feature. It allows a certain lazy style of inheritance; base ctor takes a string; subclasses can be made without explicit ctors, confident that the base ctor will be passed the string. Well, if you remember to pass it, of course - nasty stuff to document! I am tending towards 'everything is explicit' these days so maybe it should just go. |
But |
Sorry, I misread you - I tried exactly the code you gave, and yes, I get also get a ridiculous result! Genuine, first class bug! |
This is very interesting - pl.class is one of the modules that changed - require 'pl.class' returns the actual class object. So if were
then things work fine - which is why I didn't see the problem at first. By some horrible fluke class.class exists and is a function, so everything looks hunky dory until it falls over. |
Ah I see, the previous version of Penlight I was using exported something like class, Map, and Set. But as you say it just returns pl.class now, so when I do |
What I will do is detect this particular case and issue a stern warning, otherwise it is going to cause confusion! (The other option is to regard it as an error) |
I recently updated from a a previous Penlight version to latest git head and have encountered a bug which breaks my code using class() from pl.class. Hopefully this example demonstrates the problem - I don't believe there's any reason for A's constructor to be called when defining class B.
The text was updated successfully, but these errors were encountered: