[squeak-dev] Abusing #userInterfaceTheme

Stéphane Rollandin lecteur at zogotounga.net
Tue Sep 19 10:19:20 UTC 2017


> 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


More information about the Squeak-dev mailing list