[Pharo-project] How i can retrieve the global by its name?
Hi, all do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :) I know the answer: Smalltalk at: #SomeName or Smalltalk globals at: #SomeName what stroke me, just now, that both answers is wrong! It should be: #SomeName asGlobal (or suggest more appropriate/precise method name for a symbol) optionally, we could also have one, with handling absent case: #SomeName asGlobalIfAbsent: [] same , but only if present: #SomeName asGlobalIfPresent: [:global | ] Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare: (Smalltalk globals at: #Foo) doSomething and #Foo asGlobal doSomething P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different. -- Best regards, Igor Stasenko.
+ 1 Let's propose a nice protocal and we use the rewrite tool for real! This is also why I want crLog instead of Transcript show: Stef
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
Yes that's a much needed one. I used it yesterday, after creating my own crOut, I quickly looked into Pharo2.0 to find these crLog, logCr et als.. Beginner stuff like this does make it lot easier for everyone, not just beginners..! We could borrow from all other languages if any like this.. On Thu, May 2, 2013 at 12:21 PM, stephane ducasse <stephane.ducasse@free.fr>wrote:
+ 1 Let's propose a nice protocal and we use the rewrite tool for real! This is also why I want crLog instead of Transcript show:
Stef
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load. ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ] An alternative could be globalBinding, but that is more technical. #asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
On 2013-05-02, at 09:12, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
I would go with #asGlobal, though I'd prefer something like #asClass since I do not believe in anything but classes in SmalltalkDictionary :P, well we can add both can we :)
+1!! The only thing that makes me noise about asClass is #Processor asClass #Transcript asClass What do we do with those guys? :) On Thu, May 2, 2013 at 9:17 AM, Camillo Bruni <camillobruni@gmail.com>wrote:
On 2013-05-02, at 09:12, Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration |
configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted
idiom.
I would go with #asGlobal, though I'd prefer something like #asClass since I do not believe in anything but classes in SmalltalkDictionary :P, well we can add both can we :)
Sounds a bit like VW #{ } This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value. 2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
What's "global"? Even if you haven't implemented scoped environments, rather use a name that doesn't imply that you'll never have scoped environments. #asClass sounds better, except for Guillermo's point about well-known things that aren't classes. frank On 2 May 2013 09:31, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Sounds a bit like VW #{ }
This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value.
2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
On May 2, 2013, at 10:36 AM, Frank Shearar <frank.shearar@gmail.com> wrote:
What's "global"? Even if you haven't implemented scoped environments, rather use a name that doesn't imply that you'll never have scoped environments.
:) this is why I proposed asClass Now asGlobal can be interpreted as as globally accessible stuff.
#asClass sounds better, except for Guillermo's point about well-known things that aren't classes.
frank
On 2 May 2013 09:31, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Sounds a bit like VW #{ }
This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value.
2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
asGlobalOrSomethingLikeThat :-) -- Pavel On Thu, May 2, 2013 at 11:59 AM, stephane ducasse <stephane.ducasse@free.fr>wrote:
On May 2, 2013, at 10:36 AM, Frank Shearar <frank.shearar@gmail.com> wrote:
What's "global"? Even if you haven't implemented scoped environments, rather use a name that doesn't imply that you'll never have scoped environments.
:) this is why I proposed asClass
Now asGlobal can be interpreted as as globally accessible stuff.
#asClass sounds better, except for Guillermo's point about well-known things that aren't classes.
frank
On 2 May 2013 09:31, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Sounds a bit like VW #{ }
This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value.
2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration |
configuration
project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
But practically, when are you interested to query existence of a global which is not a class? Concerning asClass, it does not resolve anything, how do you specify the environment? Will it be included into the String and decoded? 'MyEnvironment.MyClass' asClass? What if you don't provide a fully qualified string? 2013/5/2 Pavel Krivanek <pavel.krivanek@gmail.com>
asGlobalOrSomethingLikeThat :-)
-- Pavel
On Thu, May 2, 2013 at 11:59 AM, stephane ducasse < stephane.ducasse@free.fr> wrote:
On May 2, 2013, at 10:36 AM, Frank Shearar <frank.shearar@gmail.com> wrote:
What's "global"? Even if you haven't implemented scoped environments, rather use a name that doesn't imply that you'll never have scoped environments.
:) this is why I proposed asClass
Now asGlobal can be interpreted as as globally accessible stuff.
#asClass sounds better, except for Guillermo's point about well-known things that aren't classes.
frank
On 2 May 2013 09:31, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Sounds a bit like VW #{ }
This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value.
2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration |
configuration
project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
But today using Smalltalk everywhere means that we are always using the same environment, and that does not look like a big deal to anybody :)... And then, that's easily solved by doing some simple stuff if you like specify an environment, isn't it? Symbol>>asClass self asClassInEnvironment: self class environment Symbol>>asClassInEnvironment: anEnvironment anEnvironment globals at: self On Thu, May 2, 2013 at 12:13 PM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
But practically, when are you interested to query existence of a global which is not a class?
Concerning asClass, it does not resolve anything, how do you specify the environment? Will it be included into the String and decoded? 'MyEnvironment.MyClass' asClass? What if you don't provide a fully qualified string?
2013/5/2 Pavel Krivanek <pavel.krivanek@gmail.com>
asGlobalOrSomethingLikeThat :-)
-- Pavel
On Thu, May 2, 2013 at 11:59 AM, stephane ducasse < stephane.ducasse@free.fr> wrote:
On May 2, 2013, at 10:36 AM, Frank Shearar <frank.shearar@gmail.com> wrote:
What's "global"? Even if you haven't implemented scoped environments, rather use a name that doesn't imply that you'll never have scoped environments.
:) this is why I proposed asClass
Now asGlobal can be interpreted as as globally accessible stuff.
#asClass sounds better, except for Guillermo's point about well-known things that aren't classes.
frank
On 2 May 2013 09:31, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Sounds a bit like VW #{ }
This sounds good to me, but don't use globalBinding, I would expect this one to answer the binding (Asociation) rather than the value.
2013/5/2 Sven Van Caekenberghe <sven@stfx.eu>
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration |
configuration
project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
But today using Smalltalk everywhere means that we are always using the same environment, and that does not look like a big deal to anybody :)...
And then, that's easily solved by doing some simple stuff if you like specify an environment, isn't it?
Symbol>>asClass self asClassInEnvironment: self class environment
Symbol>>asClassInEnvironment: anEnvironment anEnvironment globals at: self
yes :) something like that. Stef
On 2013-05-02, at 12:32, Guillermo Polito <guillermopolito@gmail.com> wrote:
But today using Smalltalk everywhere means that we are always using the same environment, and that does not look like a big deal to anybody :)...
And then, that's easily solved by doing some simple stuff if you like specify an environment, isn't it?
Symbol>>asClass self asClassInEnvironment: self class environment
Symbol>>asClassInEnvironment: anEnvironment anEnvironment globals at: self
#asClass I guess is orthogonal to the #asGlobal discussion, so I opened an issue for it: https://pharo.fogbugz.com/default.asp?10478
On 2 May 2013 14:14, Camillo Bruni <camillobruni@gmail.com> wrote:
On 2013-05-02, at 12:32, Guillermo Polito <guillermopolito@gmail.com> wrote:
But today using Smalltalk everywhere means that we are always using the same environment, and that does not look like a big deal to anybody :)...
And then, that's easily solved by doing some simple stuff if you like specify an environment, isn't it?
Symbol>>asClass self asClassInEnvironment: self class environment
Symbol>>asClassInEnvironment: anEnvironment anEnvironment globals at: self
#asClass I guess is orthogonal to the #asGlobal discussion, so I opened an issue for it:
+1 asClass is different that is must guarantee that answered object should be class or fail if there's none or it is not a class. -- Best regards, Igor Stasenko.
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives: #SomeName fromGlobal #SomeName from: someOtherEnvironment #SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment #SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one" but why bother at all. What is the advantage over this: Smalltalk at: #xx put: 1. xx inspect. cheers -ben
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
On 2 May 2013 16:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
it is not the case, when you know the name beforehand. because then why would anyone write 'Smalltalk at: #XXX' while he can just write 'XXX' it is for cases like following: name := self readNameFromSomeExternalSource. (Smalltalk at: name ifPresent: [:cls | cls doSomething)
cheers -ben
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
-- Best regards, Igor Stasenko.
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf. frank
cheers -ben
optionally, we could also have one, with handling absent case:
#SomeName asGlobalIfAbsent: []
same , but only if present:
#SomeName asGlobalIfPresent: [:global | ]
Currently, there is 941 references to 'Smalltalk' global in my pharo image. If we introduce this convenience method, it will shrink this number considerably, not saying that code will be more elegant and concise compare:
(Smalltalk globals at: #Foo) doSomething
and
#Foo asGlobal doSomething
P.S. What really strikes me is why we don't have such method from very beginning, and instead refer to 'Smalltalk' all over the places. Some things are so deeply indoctrinated in our minds, that we don't even think that it can be different.
-- Best regards, Igor Stasenko.
On 2 May 2013 16:56, Frank Shearar <frank.shearar@gmail.com> wrote:
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf.
yes, so you write: #ConfigurationOfXYZ asClass load. instead of: (Smalltalk at: #ConfigurationOfXYZ) load.
frank
-- Best regards, Igor Stasenko.
I vote for the #bind* (ej, #bindToClass) or similar. The #asX... means casting for me. I'd expect that `#Foo asClass` answer a new class named #Foo. Regards, Esteban A. Maringolo 2013/5/2 Igor Stasenko <siguctua@gmail.com>:
On 2 May 2013 16:56, Frank Shearar <frank.shearar@gmail.com> wrote:
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf.
yes, so you write:
#ConfigurationOfXYZ asClass load.
instead of:
(Smalltalk at: #ConfigurationOfXYZ) load.
frank
-- Best regards, Igor Stasenko.
the problem with #bind is that a binding is a pair (an association), not its value... so it can cause confusion (and you know murphy's law: it it can, it will). #asClass is not so bad #asClassOn: anEnvironment can work too. or: #bindedClass #bindedClassOn: anEnvironment looks clearer to me. Esteban On May 2, 2013, at 5:49 PM, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
I vote for the #bind* (ej, #bindToClass) or similar.
The #asX... means casting for me.
I'd expect that `#Foo asClass` answer a new class named #Foo.
Regards, Esteban A. Maringolo
2013/5/2 Igor Stasenko <siguctua@gmail.com>:
On 2 May 2013 16:56, Frank Shearar <frank.shearar@gmail.com> wrote:
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf.
yes, so you write:
#ConfigurationOfXYZ asClass load.
instead of:
(Smalltalk at: #ConfigurationOfXYZ) load.
frank
-- Best regards, Igor Stasenko.
#bindedXXX and #boundXXX sounds pretty static to me... It's like it was already binded. And maybe in the back it is dynamically looked up. Maybe a more abstract name can fit better: #resolveToClass ? #lookupClass ? Also (I'm pretty negative today), let's do not forget about traits! (We always do, and that gives us problems later ) On Thu, May 2, 2013 at 6:33 PM, Chris Cunningham <cunningham.cb@gmail.com>wrote:
On Thu, May 2, 2013 at 9:29 AM, Esteban Lorenzano <estebanlm@gmail.com>wrote:
#bindedClass #bindedClassOn: anEnvironment
looks clearer to me.
Esteban
maybe: #boundClass #boundClassOn: anEnvironment
On 2 May 2013 18:40, Guillermo Polito <guillermopolito@gmail.com> wrote:
#bindedXXX and #boundXXX sounds pretty static to me... It's like it was already binded. And maybe in the back it is dynamically looked up. Maybe a more abstract name can fit better:
#resolveToClass ? #lookupClass ?
Also (I'm pretty negative today), let's do not forget about traits! (We always do, and that gives us problems later )
that's why i said that whatever name you give to the method, if it ends with "class" then it should either answer a valid class or fail. In opposite to #symbol asGlobal which should fail only if such global not found. e.g.: asClass | cls | cls := self asGlobal. cls isClass ifFalse: [ self error: 'no way']. ^ cls
On Thu, May 2, 2013 at 6:33 PM, Chris Cunningham <cunningham.cb@gmail.com> wrote:
On Thu, May 2, 2013 at 9:29 AM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
#bindedClass #bindedClassOn: anEnvironment
looks clearer to me.
Esteban
maybe: #boundClass #boundClassOn: anEnvironment
-- Best regards, Igor Stasenko.
Igor Stasenko wrote:
On 2 May 2013 16:56, Frank Shearar <frank.shearar@gmail.com> wrote:
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf.
yes, so you write:
#ConfigurationOfXYZ asClass load.
instead of:
(Smalltalk at: #ConfigurationOfXYZ) load.
frank
okay. That makes sense and is nicer, and this sparked a new thought... While you might have other use cases, for that specific one case how about something like: #XYZ configuration load. cheers -ben
I like it 2013/5/2 Ben Coman <btc@openinworld.com>
Igor Stasenko wrote:
On 2 May 2013 16:56, Frank Shearar <frank.shearar@gmail.com> wrote:
On 2 May 2013 15:37, Ben Coman <btc@openinworld.com> wrote:
Sven Van Caekenberghe wrote:
On 02 May 2013, at 06:03, Igor Stasenko <siguctua@gmail.com> wrote:
Hi, all
do not think that i am drunk or vent crazy, asking such silly question, which at best should be asked only by beginner :)
I know the answer:
Smalltalk at: #SomeName
or
Smalltalk globals at: #SomeName
what stroke me, just now, that both answers is wrong!
It should be:
#SomeName asGlobal
(or suggest more appropriate/precise method name for a symbol)
ConfigurationOfXYZ globalValue project bleedingEdge load.
ConfigurationOfXYZ globalValueIfPresent: [ :configuration | configuration project bleedingEdge load ]
An alternative could be globalBinding, but that is more technical.
#asGlobal sounds like a conversion, on the other hand it is an accepted idiom.
#asGlobal feels confusing to me. It doesn't sound like a lookup. Some other alternatives:
#SomeName fromGlobal #SomeName from: someOtherEnvironment
#SomeName fromEnvironment "the current one" #SomeName fromEnvironment: someOtherEnvironment
#SomeName fromEnv: someOtherEnvironment #SomeName fromEnv "the current one"
but why bother at all. What is the advantage over this:
Smalltalk at: #xx put: 1. xx inspect.
But the use case here is when you want to reference a class that has not yet been loaded, which happens every time you run a load script for a ConfigurationOf.
yes, so you write:
#ConfigurationOfXYZ asClass load.
instead of:
(Smalltalk at: #ConfigurationOfXYZ) load.
frank
okay. That makes sense and is nicer, and this sparked a new thought... While you might have other use cases, for that specific one case how about something like:
#XYZ configuration load.
cheers -ben
+1 KISS principle at its best. 2013/5/2 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
I like it
okay. That makes sense and is nicer, and this sparked a new thought... While you might have other use cases, for that specific one case how about something like:
#XYZ configuration load.
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. Norbert
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.
Am 02.05.2013 um 13:45 schrieb Norbert Hartl <norbert@hartl.name>:
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)
what about #bound or even #bind ? can be extended to #boundObject ⦠Best -Tobias
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.
Norbert
participants (15)
-
Ben Coman -
Camillo Bruni -
Chris Cunningham -
Esteban A. Maringolo -
Esteban Lorenzano -
Frank Shearar -
Guillermo Polito -
Igor Stasenko -
Nicolas Cellier -
Norbert Hartl -
Pavel Krivanek -
S Krish -
stephane ducasse -
Sven Van Caekenberghe -
Tobias Pape