[Cuis] Determining dialect programmatically

H. Hirzel hannes.hirzel at gmail.com
Sun Jan 27 12:57:24 CST 2013


On 1/27/13, David T. Lewis <lewis at mail.msen.com> 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

Thank you David for these examples, they are illustrative. In which
repository do you keep the head (or upstream) of OSProcess. I'd like
to have a look at the other compatibility methods you have written.

--Hannes


> 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