[Cuis] Determining dialect programmatically

H. Hirzel hannes.hirzel at gmail.com
Sun Jan 27 12:49:06 CST 2013


Casey

(SystemVersion current version beginsWith: 'Cuis') ifTrue: [ #cuis ]
"Cuis 4.1"

(SystemVersion current version beginsWith: 'Squeak') ifTrue: [ #squeak
]  "Squeak 4.4"

(SystemVersion current version beginsWith: 'Pharo') ifTrue: [ #pharo ]
 "Pharo 2.0"

works fine in every variant. So this solution is preferable as it does
not involve any change on any Squeak variant. You can go ahead an do
not need any change from Squeak or Pharo.

My assumption is that only the GUI is a problem in the comparatively
simple HelpSystem of Torsten Bergmann and that this might give enough
clues to do the right thing? That means choosing the right
hierarchical list morph for the display of help topics.

--Hannes

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
>
> 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