[squeak-dev] Squeak equivalent of OSPlatform ?
tim Rowledge
tim at rowledge.org
Tue Oct 20 19:18:44 UTC 2020
> On 2020-10-20, at 11:55 AM, gettimothy via Squeak-dev <squeak-dev at lists.squeakfoundation.org> wrote:
>
> Hi folks,
>
> > On 2020-10-20, at 7:31 AM, Marcel Taeumel <marcel.taeumel at hpi.de> wrote:
> >
> > But beware of writing too much "is(Unix|Windows)"-like code across your abstraction levels because checking for more specific capabilites might produce more readable code such as "canReadFat32Device". ... which was not your question at all here. :-D
>
> Exactly - ask 'can I do this' not 'am I a wotsit'.
>
> Fascinating! I see the utility of it. thx
>
There's a hierarchy of less-dumb things to do in this area.
#isKindOf: is about the worst possible (though I'm sure somebody will chime in with an even worse idea).
Specialising is a bit (as we often do, because of lack of opportunity to get it right) to #isInteger or
#isThingyMorph is at least sensibly indicative of what you are asking.
#canHandleDoodahReverse is much better but sometimes hard to implement really cleanly across a system.
And of course there's always
[thingy doStuff]
on: MyStuffError
do: [:ex| ex helpMeObiWanKenobi]
if you prefer to beg forgiveness rather than ask permission, but exceptions always seem to scare people off. And there is some performance cost - at least, there always seemed to be. Maybe there isn't so much any more?
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Trancelators interpret messages from the dead
More information about the Squeak-dev
mailing list
|