Hi Richard,
Normally I agree with you, and prefer boolean methods
inCatagoryCc: aChar
isCategorySm: aChar
to
categoryOf: aChar == #Cc
categoryOf: aChar == #Sm
In this particular case, though, the category codes are part of the Unicode
Standard, so perhaps exposing them isn’t so bad. Moreover, there is meaning
encoded into the symbols — for example, all the letter categories start with L.
So one could write an isLetter test like this
Character >> isLetter
^ (Unicode categoryOf: self) first == $L
rather than
Character >> isLetter
Unicode inCategoryLl ifTrue: [ ^ true ].
Unicode inCategoryLm ifTrue: [ ^ true ].
Unicode inCategoryLo ifTrue: [ ^ true ].
Unicode inCategoryLt ifTrue: [ ^ true ].
Unicode inCategoryLu ifTrue: [ ^ true ].
^ false
There is still the disadvantage that a typo in the Category name (typing #L1,
for example, when one means #Ll) is likely to go undetected.
Andrew