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 Villeneuve d'Ascq

Reply via email to