Login  Register

Re: What's the correct way to create anonymous subclasses in Pharo?

Posted by Igor Stasenko on May 23, 2010; 1:46pm
URL: https://forum.world.st/What-s-the-correct-way-to-create-anonymous-subclasses-in-Pharo-tp2227809p2227844.html

On 23 May 2010 16:38, Joachim Geidel <[hidden email]> wrote:

> Am 23.05.10 15:15 schrieb Igor Stasenko:
>> Do you really need to create a meta? > > If not , then you can do just: >
>> > newClass := Rectangle clone. > newClass >   superclass: Rectangle; >
>>   organization: nil; >   methodDict: MethodDictionary new.
> Unfortunately, this doesn’t solve the problem:
>
> | newClass method |
> newClass := Rectangle clone.
> newClass
>   superclass: Rectangle;
>   organization: nil;
>   methodDict: MethodDictionary new;
>   setName: #MyRectangle.
> newClass new class name. "--> #Rectangle"
> newClass new class == newClass. "--> false"

^^^
That's really strange.
Have you tried to debug it?


> method := (newClass compile: 'testGhost ^42'
>         classified: nil
>         notifying: nil
>         trailer: newClass defaultMethodTrailer
>         ifFail: [nil]) method.
> newClass addSelectorSilently: #testGhost withMethod: method.
> newClass canUnderstand: #testGhost. "--> true".
> newClass new respondsTo: #testGhost. "--> false"
> newClass new testGhost. "--> Message not understood, should answer 42"
>
> The problem is not the MetaClass (I do need it), but that the new class
> doesn’t create instances of itself, which I find very, very strange.
>
> Best regards,
> Joachim Geidel
>
> _______________________________________________
> Pharo-users mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
>
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users