Skip to content
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

Unexpected behavior with subclassing a class with the Apply mixin #3

Closed
bivory opened this issue Dec 26, 2010 · 7 comments
Closed

Unexpected behavior with subclassing a class with the Apply mixin #3

bivory opened this issue Dec 26, 2010 · 7 comments

Comments

@bivory
Copy link

bivory commented Dec 26, 2010


require('middleclass.init')
require('middleclass-extras.init')

ParentClass = class('ParentClass')
ParentClass:include(Apply)
function ParentClass:initialize()
   super.initialize(self)
   print("Parents Init.")
end

ChildClass = ParentClass:subclass('ChildClass')
function ChildClass:initialize()
   super.initialize(self)
   print("Child Init.")
end

local inst = ChildClass:new()

Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
require 'test'
Parents Init.

@kikito
Copy link
Owner

kikito commented Dec 26, 2010

Oh my.
I'm sorry and embarrassed.
I'm not sure when I'll be able to fix this - give me one week!

@kikito
Copy link
Owner

kikito commented Jan 2, 2011

I haven't forgot about this one.

I've started tracking down the issue, but so far the root cause evades me. I'm pretty sure that the problem is not on Apply itself, but on Callbacks, which is an Apply dependency. It's also the most problematic module inside middleclass-extras.

I'll keep trying tomorrow.

@bivory
Copy link
Author

bivory commented Jan 3, 2011

No worries, it looks like it's a tougher issue. I ran out of time looking at it tonight but I'll look at it some more tomorrow too.

I think the issue has something to do with the class dictionary modification and method lookup done by the function _changeClassDict in the Callbacks module. I added some debug to the anonymous function that is set to the class dictionary __index method by _changeClassDict.

Here's the output from the child class looking for the initialize function to call:

ChildClass: looking for initialize
ChildClass: looking for initializeWithoutCallbacks
ParentClass: looking for initializeWithoutCallbacks
Parents Init.

@kikito
Copy link
Owner

kikito commented Jan 3, 2011

The "Commend and Close" button is too close to the "Comment" button... Reminds me of http://www.codinghorror.com/blog/2010/03/the-opposite-of-fitts-law.html :)

Still working on this.

@kikito
Copy link
Owner

kikito commented Jan 14, 2011

re-wrote the way classes are modified in Callbacks. closed by 314d5df

@kikito
Copy link
Owner

kikito commented Jan 14, 2011

I think this is closed now. Please test and re-open if that's not the case. Sorry it took me so long to find the problem!

@bivory
Copy link
Author

bivory commented Jan 14, 2011

It's fixed, thanks!

No worries about the time it was a tough problem. Thanks for spending your free time working on this library, it's really useful.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants