Play and crash

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Play and crash

laurent laffont
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 ?



Laurent Laffont - @lolgzs

Pharo Smalltalk Screencasts: http://www.pharocasts.com/
Blog: http://magaloma.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Play and crash

Igor Stasenko
On 13 April 2011 16:16, laurent laffont <[hidden email]> 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 ?
>
yes. because format of the class are not initialized properly.

this one works:


(Class new
  superclass: StringMorph;
  setFormat: StringMorph format;
  compile: 'step self contents: Time now printString';
  new)
    openCenteredInWorld



>
> Laurent Laffont - @lolgzs
>
> Pharo Smalltalk Screencasts: http://www.pharocasts.com/
> Blog: http://magaloma.blogspot.com/
> Developer group: http://cara74.seasidehosting.st
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Play and crash

Henrik Sperre Johansen
In reply to this post by laurent laffont
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

Reply | Threaded
Open this post in threaded view
|

Re: Play and crash

laurent laffont
Cool ! Thank you all !

Have put this at

Laurent.

On Wed, Apr 13, 2011 at 4:25 PM, Henrik Sperre Johansen <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: Play and crash

Stéphane Ducasse
In reply to this post by laurent laffont
Laurent I'm not sure that this it the good way to create classes
If you want a shorter form check how this is done in coral.

Stef

On Apr 13, 2011, at 4:16 PM, 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 ?
>
>
>
> Laurent Laffont - @lolgzs
>
> Pharo Smalltalk Screencasts: http://www.pharocasts.com/
> Blog: http://magaloma.blogspot.com/
> Developer group: http://cara74.seasidehosting.st
>