Re: [Pyobjc-dev] posing
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-01-20 06:38:46
|
On Sunday, Jan 19, 2003, at 21:33 Europe/Amsterdam, bb...@ma... wrote: > (Thinking out loud) > > Scratch that. I see what is going on. > > The pyobj_ivar contains a reference to the Python instance that > effectively provides the Python side of the implementation of the > current class; not just a binding to the class, but also to the > instance on the python side. I thought you found a clever way around this. Sorry about not mentioning this before. You could of course store the reference to the python instance in an NSHashTable, but that would probably have a negative impact on performance. > > OK. > > That makes life a bit more difficult, but I *really* want posing to > work and, afaict, that instance variable is the only thing that is > holding this back. > > But this also raises a question regarding the eventual implementation > of categories. Sort of. With Categories, one needs to add Python > implemented methods to an already existing class. > > Rephrase: Categories and posing are effectively the same problem: > they both imply that a class will preexist and that the category (or > posing class) will not add any instance variables within its > declaration. With libFFI it is possible to implement categories without adding an instance variable. One of the features of libFFI is the possibility to define closures that look like normal functions. A method in a categorie can be implemented using a closure that contains a reference to the python function implementing the method. The same trick could be used for mixed classes: __pyobjc_pythonImplementation__ would also be a closure. Ronald |