> c) self class environment at: #Array
> => this will work in the future if your code is a class which
environment/namespace/module includes the Array class you would expect

Let's say that namespaces are added; Array is now in the module
Collections.Array
My code is now in module MyProject.MyWhatever

I would imagine that in such situation I would need to change the code
anyway, because it would try to look up MyProject.Array, no?

So if the argument for asClass is based on future addition of modules, then
I will need to manually change it anyway regardless of what approach I
used, because I don't know in which namespace the class will end up.

Am I missing something?

Thanks,
Peter


On Sat, Feb 10, 2018 at 1:47 PM, Clément Bera <bera.clem...@gmail.com>
wrote:

> Hi,
>
> In short, everything that is not namespace/module compatible will be
> deprecated/changed/removed in the future, so it is not recommended to use
> it.
>
> a.2) #Array asClassInEnvironment: Smalltalk globals
> b.1) Smalltalk globals at: #Array
> => Ok-ish, note that you may need to change 'Smalltalk globals' the
> namespace/module when support for those will be added since Array will be
> in a module.
> Maybe you want instead to use instead:
>
> c) self class environment at: #Array
> => this will work in the future if your code is a class which
> environment/namespace/module includes the Array class you would expect
>
> a.1) #Array asClass
> b.2) Smalltalk at: #Array
> b.3) Smalltalk classNamed: #Array
> => In which namespace/module are you looking for #Array ? In the future
> this may be removed, alternatively it will work only for globals but not
> globals inside namespace/module which won't work since Array will be in a
> module.
>
>
> On Sat, Feb 10, 2018 at 12:57 PM, Peter Uhnák <i.uh...@gmail.com> wrote:
>
>> Hi,
>>
>> what is the canonical way to get a class from a symbol?
>>
>> a) Converting symbol into class via string protocol
>>
>> a.1) #Array asClass
>> I use this the most, because it is easy, uses unary selector, and so far
>> I've never ran into any issues. But apparently it is not good -- why?
>>
>> a.2) #Array asClassInEnvironment: Smalltalk globals
>>
>> b) Retriving the class by key from the system dictionary
>>
>> b.1) Smalltalk globals at: #Array
>>
>> b.2) Smalltalk at: #Array
>>
>> b.3) Smalltalk classNamed: #Array
>>
>> c) something else entirely?
>>
>> I get that using #asClass wouldn't work if there was a different
>> environment, however I don't even know in what situation there could be a
>> different environment, so I cannot assert how problematic it is or isn't.
>>
>> Thanks,
>> Peter
>>
>
>
>
> --
> Clément Béra
> Pharo consortium engineer
> https://clementbera.wordpress.com/
> Bâtiment B 40, avenue Halley 59650
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve+d'Ascq&entry=gmail&source=g>Villeneuve
> d
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve+d'Ascq&entry=gmail&source=g>
> 'Ascq
> <https://maps.google.com/?q=40,+avenue+Halley+59650%C2%A0Villeneuve+d'Ascq&entry=gmail&source=g>
>

Reply via email to