Cool ! Thank you all ! Have put this at http://magaloma.blogspot.com/2011/04/polymorph-counter-example.html http://magaloma.blogspot.com/2011/04/petite-horloge-revisited.html
Laurent. On Wed, Apr 13, 2011 at 4:25 PM, Henrik Sperre Johansen < [email protected]> wrote: > On 13.04.2011 16:16, laurent laffont wrote: > >> This works: >> >> counter := Class new >> superclass: Object; >> addInstVarNamed: 'counter'; >> compile: 'initialize >> counter := 0'; >> compile: 'counterString >> ^ counter asString'; >> compile: 'increment >> counter := counter + 1. >> self changed:#counterString'; >> compile: 'decrement >> counter := counter - 1. >> self changed:#counterString'; >> new. >> >> (UITheme builder newColumn: { >> UITheme builder newLabelFor: counter getLabel: #counterString getEnabled: >> nil. >> UITheme builder newRow: { >> UITheme builder newButtonFor: counter action: #increment label: '+' >> help: nil. >> UITheme builder newButtonFor: counter action: #decrement label: '-' >> help: nil. >> } >> }) openInWindowLabeled: 'Counter example'. >> >> >> >> This one crashes the VM (tried on PharoOneClick 1.2 OSX, Cog and StackVM): >> >> (Class new >> superclass: StringMorph; >> compile: 'step self contents: Time now printString'; >> new) >> openCenteredInWorld >> >> >> >> Any idea ? >> > > http://forum.world.st/test-crashing-the-cog-vm-td3393032.html > Answer in first reply :) > > Cheers, > Henry > >
