On Tue, Sep 03, 2013 at 01:48:46PM +0200, Goubier Thierry wrote:
>
> Le 03/09/2013 13:36, David T. Lewis a ?crit :
> >
> >Can you post the method here first? I'd like to check it on some Squeak
> >images
> >before it goes into the repository.
>
> Here it is (at least an example):
>
> in OSProcess class
>
> isPharo3AndLater
> "Test if we are on Pharo 3.0"
>
> ^ (Smalltalk classNamed: 'SystemVersion')
> ifNil: [ false ]
> ifNotNil: [ :v | v current type = 'Pharo' and: [ v current
> major >= 3 ] ]
The idea is right, but the details can be a PITA ;-)
- In Squeak trunk, class SystemVersion exists. But it does not understand
#type, so this fails at runtime.
- There are no implementors of #major in Squeak (but this can be rewritten
using #perform:).
- In Squeak 3.8, #ifNil:ifNotNil: requires a block with no arguments.
I did not check the other Pharo versions.
Something like this might work:
isPharo3AndLater
Smalltalk
at: #SystemVersion
ifPresent: [:cls | ((cls canUnderstand: #type) and: [ cls
canUnderstand: #major ])
ifTrue: [^ cls current type = 'Pharo' and: [ cls
current major >= 3 ]]].
^false
Dave
>
> platformName
> "After Squeak version 3.6, #platformName was moved to SmalltalkImage
> Some
> versions of Pharo move this to OSPlatform and issue deprecation
> warnings
> about the other usages. Then Pharo moved away from OSPlatform and
> deprecated
> its use."
>
> "self platformName"
>
> self isPharo3AndLater
> ifTrue: [ ^ Smalltalk os name ].
> ^ (((Smalltalk hasClassNamed: #OSPlatform)
> and: [(Smalltalk at: #OSPlatform)
> respondsTo: #platformName])
> ifTrue: [Smalltalk at: #OSPlatform]
> ifFalse: [((Smalltalk classNamed: 'SmalltalkImage')
> ifNil: [^ Smalltalk osVersion]) current])
> platformName
>
> >Thanks!
> >Dave
> >
> >>
> >>>Dave
> >>>
> >>>
> >>>
> >>>
> >>
> >>--
> >>Thierry Goubier
> >>CEA list
> >>Laboratoire des Fondations des Syst?mes Temps R?el Embarqu?s
> >>91191 Gif sur Yvette Cedex
> >>France
> >>Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
> >
> >
> >
>
> --
> Thierry Goubier
> CEA list
> Laboratoire des Fondations des Syst?mes Temps R?el Embarqu?s
> 91191 Gif sur Yvette Cedex
> France
> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95