[squeak-dev] The Trunk: Multilingual-tpr.185.mcz

H. Hirzel hannes.hirzel at gmail.com
Wed Oct 9 14:29:36 UTC 2013


On 10/9/13, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> On 09.10.2013, at 00:52, Levente Uzonyi <leves at elte.hu> wrote:
>
>> On Tue, 8 Oct 2013, Nicolas Cellier wrote:
>>
>>> I would prefer decent default being ^Unicode, if ever (EncodedCharSets
>>> at:1) isNil for some (bad) reason.
>>
>> Wouldn't it be better to fill the EncodedCharSets array with Unicode by
>> default in EncodedCharSet class >> #initialize? (replace the line
>>
>> 	EncodedCharSets := Array new: 256.
>>
>> with:
>>
>> 	EncodedCharSets := Array new: 256 withAll: Unicode
>> )
>>
>> That way #charsetAt: could be simply
>>
>> 	^EncodedCharSets at: encoding + 1
>>
>>
>> Levente
>
>
> IMHO that would obscure the intention. It is technically equivalent, yes,
> but I'd like to see the explicit default. Most readable might be this:
>
> 	^ (EncodedCharSets at: encoding + 1) ifNil: [Unicode]
>
> We could even skip the "+ 1" part and only store the encoded charsets in
> EncodedCharSets. Unicode is not encoded, which is well-expressed by the code
> 0.
>



> 	^ (EncodedCharSets at: encoding ifAbsent: [nil]) ifNil: [Unicode]


+1 for this as intention-revealing.  Tells us that Unicode is the default.


> - Bert -
>
>>>        charsetAt: encoding
>>>      + "Find  the char set encoding that matches 'encoding'; return a
>>> decent default rather than nil"
>>>      +       ^ (EncodedCharSets at: encoding + 1) ifNil: [EncodedCharSets
>>> at: 1].
>>>      -
>>>      -       ^ EncodedCharSets at: encoding + 1 ifAbsent:
>>> [EncodedCharSets at: 1].
>>>        !
>
>
>
>
>


More information about the Squeak-dev mailing list