[Pharo-project] Anonymous subclasses support
Hi guys, Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools. The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it... I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects. What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something... -- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On 16 December 2012 19:42, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi guys,
Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools.
The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it...
I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects.
Depends what you wanna do.
What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something...
Using anonymous classes with tools which written to work with public ones will never work. There are too many places on different levels of system with strong assumptions about how things are organized. Perhaps if you tell, what you trying to do, we can see how to deal with problems. P.S. wellcome to bizarre world of metaprogramming :)
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Best regards, Igor Stasenko.
On Sun, Dec 16, 2012 at 9:41 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 19:42, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi guys,
Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools.
The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it...
I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects.
Depends what you wanna do.
What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something...
Using anonymous classes with tools which written to work with public ones will never work. There are too many places on different levels of system with strong assumptions about how things are organized. Perhaps if you tell, what you trying to do, we can see how to deal with problems.
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;) At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating... The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes) Well that's about it for now... P.S. wellcome to bizarre world of metaprogramming :)
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Best regards, Igor Stasenko.
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :). Stef
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On Sun, Dec 16, 2012 at 11:41 PM, Ciprian Teodorov < ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
actually no the #classChange selector gives me a nil ? I don't know...
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
could you send a snippet that generate code? Stef On Dec 16, 2012, at 11:41 PM, Ciprian Teodorov wrote:
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro <PharoScreenshot.png>
@Igor that's an idea ... I think I'll go with that for the initial version @stef I'll send a snippet this evening Cheers On Dec 17, 2012 9:39 AM, "Stéphane Ducasse" <stephane.ducasse@inria.fr> wrote:
could you send a snippet that generate code?
Stef
On Dec 16, 2012, at 11:41 PM, Ciprian Teodorov wrote:
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse <
stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro <PharoScreenshot.png>
Hi stef, I did some investigations and it seems to me that the problem comes from the ChangesBrowser. It stores the changes in a Set which in turn changes the order of declarations... So how can I define a method in a class that does not exit? The PickListModel is the culprit ;) Bellow you will find the snippet that I have promised... model := RBNamespace new . className := 'ANewClassForTheSystem' asSymbol. model defineClass: ('<1s> subclass: #<2s> instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: <3p>' expandMacrosWith: 'NBExternalStructure' with: className with: 'JustTesting'). model compile: 'myInstanceMethod ^''Hello world'' ' in: (model classNamed: className) classified: 'method declaration'. model compile: 'myClassMethod ^self new ' in: (model metaclassNamed: className) classified: 'method declaration'. "(ChangesBrowser changes: model changes ) openWithSpec ." (ChangesBrowser new change: model changes ) openWithSpec . Cheers On Mon, Dec 17, 2012 at 10:56 AM, Ciprian Teodorov < ciprian.teodorov@gmail.com> wrote:
@Igor that's an idea ... I think I'll go with that for the initial version
@stef I'll send a snippet this evening
Cheers On Dec 17, 2012 9:39 AM, "Stéphane Ducasse" <stephane.ducasse@inria.fr> wrote:
could you send a snippet that generate code?
Stef
On Dec 16, 2012, at 11:41 PM, Ciprian Teodorov wrote:
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse <
stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro <PharoScreenshot.png>
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On Mon, Dec 17, 2012 at 7:47 PM, Ciprian Teodorov < ciprian.teodorov@gmail.com> wrote:
Hi stef,
I did some investigations and it seems to me that the problem comes from the ChangesBrowser. It stores the changes in a Set which in turn changes the order of declarations... So how can I define a method in a class that does not exit? The PickListModel is the culprit ;)
changing its pickedItemsHolder from Set new asValueHolder to OrderedCollection new asValueHolder fixes my issue ... but of course I don't really now where in the system the items are used as set ... Maybe we can change its name to PickSetModel or PickUnorderedListModel... by the way I find PickListModel not a good name at all It probably should be PickedListModel -> for the items pick*ed* from a list
Bellow you will find the snippet that I have promised...
model := RBNamespace new . className := 'ANewClassForTheSystem' asSymbol. model defineClass: ('<1s> subclass: #<2s> instanceVariableNames: '''' classVariableNames: '''' poolDictionaries: '''' category: <3p>' expandMacrosWith: 'NBExternalStructure' with: className with: 'JustTesting'). model compile: 'myInstanceMethod ^''Hello world'' ' in: (model classNamed: className) classified: 'method declaration'.
model compile: 'myClassMethod ^self new ' in: (model metaclassNamed: className) classified: 'method declaration'. "(ChangesBrowser changes: model changes ) openWithSpec ." (ChangesBrowser new change: model changes ) openWithSpec .
Cheers
On Mon, Dec 17, 2012 at 10:56 AM, Ciprian Teodorov < ciprian.teodorov@gmail.com> wrote:
@Igor that's an idea ... I think I'll go with that for the initial version
@stef I'll send a snippet this evening
Cheers On Dec 17, 2012 9:39 AM, "Stéphane Ducasse" <stephane.ducasse@inria.fr> wrote:
could you send a snippet that generate code?
Stef
On Dec 16, 2012, at 11:41 PM, Ciprian Teodorov wrote:
On Sun, Dec 16, 2012 at 11:02 PM, Stéphane Ducasse <
stephane.ducasse@inria.fr> wrote:
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Can you tell us what is the problem you got with RBNamespace? Because if we know we can try to fix it :).
When executing the refactorings that generate my code I get a DNU... (see attached .png) it seem that RBAddMethodChange does not implement the #includesSelector:
Stef
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro <PharoScreenshot.png>
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On 16 December 2012 22:38, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 9:41 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 19:42, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi guys,
Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools.
The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it...
I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects.
Depends what you wanna do.
What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something...
Using anonymous classes with tools which written to work with public ones will never work. There are too many places on different levels of system with strong assumptions about how things are organized. Perhaps if you tell, what you trying to do, we can see how to deal with problems.
I'm writing a FFI generator for Pharo that uses libclang to parse header files and generates nativeboost mapping as output. The beast is almost working (I can get libclang mapping, the core.h header)but there are still some small issues. So, that's why I've been poking at nativeboost ;)
At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand of visible classes, so that the user might get a chance to understand something of what I'm generating...
indirection is your savior :) You can implement similar functionality as in ExternalArray, but instead of generating a pair of methods per class, make a class which holds following information: data type getter setter where getter and setter is generated functions for converting external value back and forth.. then in at: at:put: primitives should call these functions. With this setup you will need only single class, which instances responsible for holding rest of information about type & handling conversion of values. I know , this will make code a bit more complicated, but at the end you will not need to deal with anonymous classes anymore. Also, since you need only single getter/setter per value type, you can share them via cache controlled by class side. So, instead of climbing the wall, you can walk around it ;)
The thing is this evening after 4-5 hours of looking around my conclusion is. In pharo 1.4 the anonymous subclasses are breaking the tools, and in the brand new pharo 2.0 the refactoring tools (RBNamespace & company) are not working as they should.... so i'm stuck with 1.4 for now (and still telling to myself that I do not want to bloat the image with many classes)
Well that's about it for now...
-- Best regards, Igor Stasenko.
Behavior new I fixed it to work long time ago. Now you have to pay attention because depending on what you want to do you will have to compile in these anonymous classes some methods. Now I would avoid them. Stef
Hi guys,
Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools.
The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it...
I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects.
What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something...
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On Sun, Dec 16, 2012 at 10:36 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
Behavior new I fixed it to work long time ago.
Now you have to pay attention because depending on what you want to do you will have to compile in these anonymous classes some methods.
Now I would avoid them.
For now I was just pocking around, trying to use the nativeboost arrays and use them as a base for defining static arrays but well... we'll see where I get in the next episode ;)
Stef
Hi guys,
Can somebody tell what is the correct way of creating anonymous classes in Pharo? When I say correct way I mean something that does not break the image or the tools.
The thing is that we can use them in NativeBoost and I cannot stop running into errors because of these anonymous classes. Is it just me or maybe we should do something about it...
I am really frustrated about this thing because everybody knows that we can do it... but at the end of the day it is not working properly, and has bizzare side effects.
What about an official API for doing this? Or at least a way to check if your class is anonymous so that we can refactor the tools to ignore them or something...
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
participants (3)
-
Ciprian Teodorov -
Igor Stasenko -
Stéphane Ducasse