Thanks for the clarifications! Oscar
On 29 Aug 2014, at 14:01 , Camille Teruel <[email protected]> wrote: > > On 29 août 2014, at 13:38, Oscar Nierstrasz <[email protected]> > wrote: > >> >> Following up: >> >> Behavior new compile: 't ^ true’ >> >> fails since #compile: is defined in TBehavior and depends on >> #basicLocalSelectors which is defined only in Class, MetaClass and >> TraitBehavior. >> >> It seems like #basicLocalSelectors should be abstract in TBehavior. >> Alternatively the implementation should be moved to TBehavior and the field >> localSelectors should be pushed up to Behavior. Am I missing something? > > You're right, it should be possible to compile methods into an instance of > behavior. > IIRW, it was possible in Pharo 2 but we didn't pay enough attention to ensure > that it is always possible. So if we can make it work again we should add > your test somewhere for that. > About moving localSelectors to Behavior: I'm not sure that Behavior should be > aware of traits. I prefer to keep Behavior minimal (it is already too messy > IMO). > Also for Pharo 4 there is other issues introduced by the integration of slots > (slots are now needed by Opal for compilation): > - we should move slot API to Behavior > - make sure that iv and format ivs are consistent with each other > So there is some work to be done to make it work again... > >> Oscar >> >> On 29 Aug 2014, at 12:26 , Oscar Nierstrasz <[email protected]> >> wrote: >> >>> >>> Hi folks, >>> >>> I was updating my lecture on Reflection for the Software Design and >>> Evolution course, and I see now that anonymous classes can no longer be >>> instances of Behavior but must be instances of Class. If you try to >>> compile a method on an instance of Behavior, it fails. >>> (basicLocalSelectors is not understood) >>> >>> Am I missing something? >>> >>> Cheers, >>> Oscar >>> >>> testPrimitiveChangeClassTo >>> | anonClass browser | >>> >>> anonClass := Class new. “must be Class, not Behavior" >>> anonClass superclass: Browser. >>> anonClass setFormat: Browser format. >>> >>> browser := Browser new. >>> browser primitiveChangeClassTo: anonClass new. >>> anonClass compile: 'thisIsATest ^ 2'. >>> >>> self assert: browser thisIsATest = 2. >>> self should: [Browser new thisIsATest] >>> raise: MessageNotUnderstood. >>> >>> >> >> > >
