[squeak-dev] Class names, Symbols, and Strings (was: The Trunk: EToys-topa.123.mcz)

Bert Freudenberg bert at freudenbergs.de
Wed Apr 8 08:44:49 UTC 2015


On 08.04.2015, at 10:09, Tobias Pape <Das.Linux at gmx.de> wrote:
> 
> Hi Eliot
> 
> On 08.04.2015, at 09:56, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
>> Hi Tobias,
>> 
>>    hasClassNamed: and symbols are to be preferred to avoid the cost of interning.  
> 
> I don't quite understand that. When I use a symbol, it already has been interned,
> either during method-compilation or because I created it. How is interning avoided here?
>  I thought this was the very reason to not pass a Symbol to hasClassNamed?

My reason for preferring a Symbol over a String is to avoid paying the storage space twice. With a Symbol, the literal will be shared.

> What about its sibling classNamed: (or classOrTraitNamed:)?

That implementation uses asSymbol anyway, so it's actually preferable to pass a Symbol.

- Bert -

PS: Meaningful Subjects Are A Good Idea™
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4115 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150408/6b30a423/smime.bin


More information about the Squeak-dev mailing list