On 2 May 2013 13:45, Norbert Hartl <norbert@hartl.name> wrote:
Am 02.05.2013 um 06:03 schrieb Igor Stasenko <siguctua@gmail.com>:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
I think if you write
asGlobalWhat?
the problems with this becomes visible. As Steph wrote there is asClass which does it for the case you are looking for a class. I'm not sure how common the use case
Smalltalk at: #foo put: somethingThatIsNotAClass
is. Your selector is somewhat orthogonal to asClass as you define access via reachability and not via type. But trying to imagine the future asGlobal is not a good selector. At least I hope the "global" will go away completely. In that case it wouldn't be good to rely on. Another possibility that would make sense is
asBinding (or a better name)
but that would only be good if it would search scopes upwards. So it can look into e.g. block -> method -> class -> environment -> ? And that would defeat the purpose of your mail in another way.
So what is your rationale? My gut says I like the idea but I can't think of a useful selector/concept to make it a viable option.
Maybe #asSmalltalkGlobal then? And lets not derail into "what if tomorrow we will have no globals etc".. when that tomorrow will happen, the code which uses "Smalltalk at: ... " will still exists, it won't disappear in one night. My rationale is that you don't write: Float fromInteger: 1 you write: 1 asFloat you could argue that it is completely different thing. And i argue it is the same: it is mapping from one set into another. Mapping from integer to float , or mapping from a name to global.
Norbert
-- Best regards, Igor Stasenko.