[squeak-dev] Abusing #userInterfaceTheme

Marcel Taeumel marcel.taeumel at hpi.de
Tue Sep 19 11:52:49 UTC 2017


Well, not good. :) Then you would rely on a quite hidden side effect. You do not know in advance how the object stored in a theme will be used by the client. It is not always a simple instVar write.

Consider this example:

slider borderColor: ((self userInterfaceTheme borderColorModifier
ifNil: [ [:c | c adjustBrightness: -0.3] ]) value: aColor).

Best,
Marcel
Am 19.09.2017 12:19:17 schrieb Stéphane Rollandin <lecteur at zogotounga.net>:
> Well, on the one hand, we do want to avoid the need for parentheses:
>
> self color: (self themed: #color)
Hmm... if we are sure that all setters are always named from the
getters, then this may do the trick:

Object>>getThemed: aSelector ifNone: defaultValue
self perform: (aSelector, ':') asSymbol
with: ((self themed: aSelector) ifNil: [defaultValue])

Then

self color: (self userInterfaceTheme color ifNil: [Color yellow])

would become:

self getThemed: #color ifNone: Color yellow


The only hurdle I see is the #asSymbol send which may slow things down a
little.


Stef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170919/c28c4d76/attachment.html>


More information about the Squeak-dev mailing list