[Newbies] constants

Marcin Tustin mm3 at zepler.net
Mon Sep 29 11:00:57 UTC 2008


The initialize method on the class side will be called only when *the class*
is initialised. You are thinking of the instance-side initialize method
which is called each time you create an instance.

On 9/29/08, Mark Volkmann <mark at ociweb.com> wrote:
>
> On Sep 28, 2008, at 11:32 PM, K. K. Subramaniam wrote:
>
> On Sunday 28 Sep 2008 7:26:43 pm Mark Volkmann wrote:
>>
>>> I think my main issue is scoping. I want to define a constant that is
>>> associated with a class to avoid name conflicts.
>>>
>> See classes Color, Cursor or Float for examples of scoped constants:
>>  Color red
>>  Cursor wait
>>  Float pi
>>
>> For constants that should be exposed to a few (but not all) classes, use
>> pool
>> dictionaries.
>>
>
> Thanks! This brings up another question. Where is a good place to
> initialize a constant? I see in the case of "Float pi" that it is held in a
> class variable that is initialized in the initialize method. Isn't it the
> case that the initialize method is only called if a Float object is created?
> Also, isn't it called every time a Float object is created? It seems that
> would mean if I followed that pattern for one of my own constants then I
> wouldn't be sure it was set and I'd pay the cost of setting it many times.
>
> ---
> Mark Volkmann
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080929/daa49461/attachment-0001.htm


More information about the Beginners mailing list