what's new in 3.8
stéphane ducasse
ducasse at iam.unibe.ch
Sun Dec 12 10:27:27 UTC 2004
>> It allows you to create a minimal lighwight class with no name by
>> doing "Behavior new". This can for example be used for emulating
>> instance specific behavior:
>> testChange
>> "self run: #testChange"
>> | behavior browser |
>> behavior := Behavior new.
>> behavior superclass: Browser.
>> behavior setFormat: Browser format.
>> browser := Browser new.
>> browser primitiveChangeClassTo: behavior new.
>> behavior compile: 'thisIsATest ^ 2'.
>> self assert: browser thisIsATest = 2.
>> self should: [Browser new thisIsATest] raise:
>> MessageNotUnderstood.
>
> that's interesting. however, I noticed that alt-n on "#thisIsATest"
> gives no implementor. also, I did
Normally since anonyous class are not registered in SystemDictionary.
>
> behavior compile: 'anotherTest ^ self gloup'
>
> and alt-m on "gloup" also gives no senders.
>
> more unpleasantly,
>
> browser anotherTest
>
> raises a debugger as expected (since #gloup is undefined), but the
> debugger fails with a DNU on Behavior>>organization when its first
> lines are selected.
>
> I would be very interested in this type of anonymous Behavior, but I
> would need the instance specific code to be accessible through the
> usual requests. would this be possible ?
Yes but you would have to work a bit :)
Not however that a BIG limit is that you cannot add instance specific
state since changeClass have to have the same format. \
Have fun but save your image before running the tests :)
Stef
More information about the Squeak-dev
mailing list
|