About KCP and automatic initialize
ducasse
ducasse at iam.unibe.ch
Mon Sep 15 20:14:33 UTC 2003
hi andreas
You amazed me. This is coolest snippet I read until now.
This is art :)))
and the results are impressive:
In a full 3.6 system this yields:
count: 1756
used: 740
which means roughly 42% of all of the classes already use this pattern.
In 3.5 I got
count 1858
used 831 -> 44% (because we already remove alice and other)
I agree with everything you said.
Thanks sincerly thanks.
Stef
On Lundi, sep 15, 2003, at 21:35 Europe/Zurich, Andreas Raab wrote:
> Object compile: 'fooInitialize self error: ''Yes initialize is
> called'''.
> initializer := Object compiledMethodAt: #fooInitialize.
> count := used := 0.
> Smalltalk allClasses do:[:cls|
> count := count + 1.
> (cls == CompiledMethod) ifFalse:[
> fooClass := cls subclass: ('Foo', cls name) asSymbol
> instanceVariableNames: ''
> classVariableNames: '' poolDictionaries: '' category: 'Foo'.
> fooClass addSelector: #initialize withMethod: initializer.
> [fooClass new] on: Error do:[:ex|
> ex messageText = 'Yes initialize is called'
> ifTrue:[used := used + 1].
> ex return].
> fooClass removeFromSystem.
> ].
> ].
> Object removeSelector: #fooInitialize.
More information about the Squeak-dev
mailing list
|