About KCP and automatic initialize

Andreas Raab andreas.raab at gmx.de
Mon Sep 15 21:01:09 UTC 2003


> You amazed me.   This is coolest snippet I read until now.
> This is art :)))

No, just making a point ;-) Being that a system which allows this kind of
arcane constructions should and could also be much more easily accessible
(this example was just too great to leave it out). A few well-choosen and
well-taught patterns could get us a long way towards this end. Not that I
want to stop there of course, but a little change is better than no change
at all (and Smalltalk hasn't seen any change in 25 years). After all, I need
to think about what "comes after" for people who have mastered Tweak or
Croquet in their end-user forms, respectively ;-)

Cheers,
  - Andreas

> 
> 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