[squeak-dev] The Trunk: Kernel-ul.709.mcz
Levente Uzonyi
leves at elte.hu
Wed Sep 5 12:41:51 UTC 2012
On Wed, 5 Sep 2012, Tobias Pape wrote:
> Am 05.09.2012 um 13:27 schrieb Frank Shearar:
>
>> On 5 September 2012 12:10, Tobias Pape <Das.Linux at gmx.de> wrote:
>>> Am 05.09.2012 um 11:42 schrieb Frank Shearar:
>>>
>>>> On 4 September 2012 18:03, Frank Shearar <frank.shearar at gmail.com> wrote:
>>>>
>>>> OK, so how about pushing the env ifNil: [] into ensure? Do you think
>>>> this would look a bit less weird?:
>>>>
>>>> Process >> #environmentAt: key ifAbsentPut: aBlock
>>>>
>>>> self ensureEnvironment.
>>>> ^env at: key ifAbsentPut: aBlock
>>>>
>>>> I dislike the necessity to remember to "self ensureEnvironment" before
>>>> any access of env, but I take your point regarding exposing the
>>>> dictionary.
>>>
>>>
>>> What about
>>>
>>> Process >> #pvtEnvironment
>>>
>>> ^ env ifNil: [env := Dictionary new]
>>>
>>> Process >> #environmentAt: key ifAbsentPut: aBlock
>>>
>>> ^ self pvtEnvironment at: key ifAbsentPut: aBlock
>>>
>>>
>>> (naming subject to bikeshedding,
>>> eg, name it pvtEnvironment, ensureEnvironment, ensuredEnvironment,
>>> theEnvironment ...)
>>
>> While #pvtEnvironment is more forceful than categorising #environment
>> as 'private' in indicating "don't use this", I expect Levente to still
>> say "yes but that still exposes the dictionary!"
>
>
> so does aProcess instVarNamed: 'env' (SCRN)
When you use reflection, then you know anything can happen. If it's
exposed via a single message, then you'll probably think it's okay to
access it.
> The point is that the
> …
> self ensureEnvironment.
> env …
> relies too much on side-effects, imho.
>
> Two things here:
> 1) what is the harm of exposing the dictionary?
> If you use it, you are guilty nonetheless
If the environment dictionary is accessed from another process, then
things can go really bad.
> 2) What speaks against initalizing the env in an #initialize?
> That would remove these checks alltogether :)
Most processes don't use the environment. We should check how it
would affect mass process creation.
Levente
>
> Best
> -Tobias
>
>
>
>
More information about the Squeak-dev
mailing list
|