[Cuis] Determining dialect programmatically

Juan Vuletich juan at jvuletich.org
Mon Jan 28 09:13:17 CST 2013


Hi David.

I agree. I'm adding a comment on them, warning about their use.

Cheers,
Juan Vuletich

David T. Lewis wrote:
> On Sun, Jan 27, 2013 at 12:22:45PM -0300, Juan Vuletich wrote:
>   
>> Hi Casey,
>>
>> Casey Ransberger wrote:
>>     
>>> I'm thinking I might want to do some stuff conditionally based on 
>>> platform, is the best way to find out whether I'm on Pharo/Squeak/Cuis?
>>>
>>> (SystemVersion current version beginsWith: 'Cuis') ifTrue: [ #foo ]
>>> (SystemVersion current version beginsWith: 'Squeak') ifTrue: [ #bar ]
>>> (SystemVersion current version beginsWith: 'Pharo') ifTrue: [ #baz ]
>>>
>>> -- 
>>> Casey Ransberger
>>>       
>> This sounds right to me. But if you want to add #isCuis, #isSqueak, 
>> #isPharo, etc to SystemDictionary or some base class, that would be ok 
>> too. You'd need to convince the Squeak and Pharo folks to add them too. 
>> It looks like they would agree.
>>     
>
> Just a note of caution - keeping up with these differences can be a real
> pain. Pharo is particularly challenging, because there are multiple incompatible
> versions of Pharo, and some versions raise deprecation warnings about the
> previously correct usage in another version. This means that testing for
> #isPharo is usually not sufficient, because Pharo 1.4 is very different from
> Pharo 2.0. The same would be true for Squeak but to a much lesser degree.
>
> Here are a couple of compatibility methods from OSProcess to illustrate:
>
>    OSProcess class>>directoryEntryNames: path
>       "Use FileReference if available, otherwise use traditional FileDirectory"
>    
>       ^ (path respondsTo: #asFileReference)
>          ifTrue: [ (path perform: #asFileReference) children collect: [:e | e perform: #basename] ]
>          ifFalse: [ ((Smalltalk at: #FileDirectory) on: path) entries collect: [:e | e name] ]
>    
>    
>    OSProcess class>>osVersion
>       "After Squeak version 3.6, #osVersion was moved to SmalltalkImage. Some
>       versions of Pharo move this to OSPlatform and issue deprecation warnings
>       about the other usages."
>    
>       ^ (((Smalltalk hasClassNamed: #OSPlatform)
>             and: [(Smalltalk at: #OSPlatform)
>                   respondsTo: #osVersion])
>          ifTrue: [Smalltalk at: #OSPlatform]
>          ifFalse: [((Smalltalk classNamed: 'SmalltalkImage')
>                ifNil: [^ Smalltalk osVersion]) current]) osVersion
>
> I'm sure there are better ways to do this, but keeping up with multiple image
> versions can be a lot of work and the code can get quite ugly.
>
> (I have not yet tried updating OSProcess for Cuis, but I do want to do so).
>
> Dave
>
>
> _______________________________________________
> Cuis mailing list
> Cuis at jvuletich.org
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>
>
>   





More information about the Cuis mailing list