Hi
VAST has an #asClass method on Symbol that does more or less this: Symbol >> #asClass ^ Smalltalk at: self This can be quite handy if you want to refer to a class that is not there a compile time, eg. Metacello. Think: #ConfigurationOfSeaside30 asClass load Cheers Philippe _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On Thu, 22 Jul 2010, Philippe Marschall wrote:
> Hi > > VAST has an #asClass method on Symbol that does more or less this: > > Symbol >> #asClass > ^ Smalltalk at: self What about this? ^Smalltalk at: self ifAbsent: nil So one could also write: #MyClass asClass ifNotNil: [ :myClass | ... ] Levente > > This can be quite handy if you want to refer to a class that is not > there a compile time, eg. Metacello. > > Think: > #ConfigurationOfSeaside30 asClass load > > Cheers > Philippe > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
sounds cool :)
>> VAST has an #asClass method on Symbol that does more or less this: >> >> Symbol >> #asClass >> ^ Smalltalk at: self > > What about this? > > ^Smalltalk at: self ifAbsent: nil ^Smalltalk globals at: self ifAbsent: nil > > > So one could also write: > > #MyClass asClass ifNotNil: [ :myClass | ... ] _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
now after some thinking. I'm wondering why this is good addition or the name could be better.
I do not know... thinking aloud. > sounds cool :) > >>> VAST has an #asClass method on Symbol that does more or less this: >>> >>> Symbol >> #asClass >>> ^ Smalltalk at: self >> >> What about this? >> >> ^Smalltalk at: self ifAbsent: nil > > ^Smalltalk globals at: self ifAbsent: nil >> >> >> So one could also write: >> >> #MyClass asClass ifNotNil: [ :myClass | ... ] > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
why not let #asClass raise an error and make another one like
Symbol>>asClassIfAbsent: aBlock ^Smalltalk globals at: self ifAbsent: aBlock. ? On Thu, Jul 22, 2010 at 10:45 AM, Stéphane Ducasse <[hidden email]> wrote: now after some thinking. I'm wondering why this is good addition or the name could be better. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
I see two problems with this:
1. #World asClass does not return a class. 2. We are trying to remove all direct references to the Smalltalk namespace, this however hardcodes the Smalltalk namespace again. Lukas 2010/7/22 Guillermo Polito <[hidden email]>: > why not let #asClass raise an error and make another one like > > Symbol>>asClassIfAbsent: aBlock > ^Smalltalk globals at: self ifAbsent: aBlock. > > ? > > On Thu, Jul 22, 2010 at 10:45 AM, Stéphane Ducasse > <[hidden email]> wrote: >> >> now after some thinking. I'm wondering why this is good addition or the >> name could be better. >> I do not know... thinking aloud. >> >> >> > sounds cool :) >> > >> >>> VAST has an #asClass method on Symbol that does more or less this: >> >>> >> >>> Symbol >> #asClass >> >>> ^ Smalltalk at: self >> >> >> >> What about this? >> >> >> >> ^Smalltalk at: self ifAbsent: nil >> > >> > ^Smalltalk globals at: self ifAbsent: nil >> >> >> >> >> >> So one could also write: >> >> >> >> #MyClass asClass ifNotNil: [ :myClass | ... ] >> > >> > >> > _______________________________________________ >> > Pharo-project mailing list >> > [hidden email] >> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Guillermo Polito
On Thu, 22 Jul 2010, Guillermo Polito wrote:
> why not let #asClass raise an error and make another one like > > Symbol>>asClassIfAbsent: aBlock > ^Smalltalk globals at: self ifAbsent: aBlock. > > ? Because it saves #asClassIfPresent: and #asClassIfAbsent:ifPresent:. Which are probably more common than #asClassIfAbsent:. #Foo asClass ifNil: [...] #Foo asClass ifNilNotNil: [ :foo | ...] #Foo asClass ifNil: [...] ifNotNil: [ :foo | ...] Levente > > On Thu, Jul 22, 2010 at 10:45 AM, Stéphane Ducasse < > [hidden email]> wrote: > >> now after some thinking. I'm wondering why this is good addition or the >> name could be better. >> I do not know... thinking aloud. >> >> >>> sounds cool :) >>> >>>>> VAST has an #asClass method on Symbol that does more or less this: >>>>> >>>>> Symbol >> #asClass >>>>> ^ Smalltalk at: self >>>> >>>> What about this? >>>> >>>> ^Smalltalk at: self ifAbsent: nil >>> >>> ^Smalltalk globals at: self ifAbsent: nil >>>> >>>> >>>> So one could also write: >>>> >>>> #MyClass asClass ifNotNil: [ :myClass | ... ] >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
On Thu, 22 Jul 2010, Lukas Renggli wrote:
> I see two problems with this: > > 1. #World asClass does not return a class. #classNamed: can solve this. > > 2. We are trying to remove all direct references to the Smalltalk > namespace, this however hardcodes the Smalltalk namespace again. self environment can solve this. Levente > > Lukas > > 2010/7/22 Guillermo Polito <[hidden email]>: >> why not let #asClass raise an error and make another one like >> >> Symbol>>asClassIfAbsent: aBlock >> ^Smalltalk globals at: self ifAbsent: aBlock. >> >> ? >> >> On Thu, Jul 22, 2010 at 10:45 AM, Stéphane Ducasse >> <[hidden email]> wrote: >>> >>> now after some thinking. I'm wondering why this is good addition or the >>> name could be better. >>> I do not know... thinking aloud. >>> >>> >>>> sounds cool :) >>>> >>>>>> VAST has an #asClass method on Symbol that does more or less this: >>>>>> >>>>>> Symbol >> #asClass >>>>>> ^ Smalltalk at: self >>>>> >>>>> What about this? >>>>> >>>>> ^Smalltalk at: self ifAbsent: nil >>>> >>>> ^Smalltalk globals at: self ifAbsent: nil >>>>> >>>>> >>>>> So one could also write: >>>>> >>>>> #MyClass asClass ifNotNil: [ :myClass | ... ] >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
>> 1. #World asClass does not return a class.
> > #classNamed: can solve this. No, it still returns an instance of PasteUpMorph. >> 2. We are trying to remove all direct references to the Smalltalk >> namespace, this however hardcodes the Smalltalk namespace again. > > self environment can solve this. No, what will #asClass return if you have different instances of Smalltalk? Lukas -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
I also see problems, in my opinion, conceptually is wrong.
Why does a Symbol needs to understand this behavior? Just because the current binding of class names are symbols? Fernando On Jul 22, 2010, at 4:09 PM, Lukas Renggli wrote: > I see two problems with this: > > 1. #World asClass does not return a class. > > 2. We are trying to remove all direct references to the Smalltalk > namespace, this however hardcodes the Smalltalk namespace again. > > Lukas > > 2010/7/22 Guillermo Polito <[hidden email]>: >> why not let #asClass raise an error and make another one like >> >> Symbol>>asClassIfAbsent: aBlock >> ^Smalltalk globals at: self ifAbsent: aBlock. >> >> ? >> >> On Thu, Jul 22, 2010 at 10:45 AM, Stéphane Ducasse >> <[hidden email]> wrote: >>> >>> now after some thinking. I'm wondering why this is good addition or the >>> name could be better. >>> I do not know... thinking aloud. >>> >>> >>>> sounds cool :) >>>> >>>>>> VAST has an #asClass method on Symbol that does more or less this: >>>>>> >>>>>> Symbol >> #asClass >>>>>> ^ Smalltalk at: self >>>>> >>>>> What about this? >>>>> >>>>> ^Smalltalk at: self ifAbsent: nil >>>> >>>> ^Smalltalk globals at: self ifAbsent: nil >>>>> >>>>> >>>>> So one could also write: >>>>> >>>>> #MyClass asClass ifNotNil: [ :myClass | ... ] >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
On Thu, 22 Jul 2010, Lukas Renggli wrote:
>>> 1. #World asClass does not return a class. >> >> #classNamed: can solve this. > > No, it still returns an instance of PasteUpMorph. That's a bug, isn't it? > >>> 2. We are trying to remove all direct references to the Smalltalk >>> namespace, this however hardcodes the Smalltalk namespace again. >> >> self environment can solve this. > > No, what will #asClass return if you have different instances of Smalltalk? A Class or nil. Levente > > Lukas > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On 22 July 2010 16:30, Levente Uzonyi <[hidden email]> wrote:
> On Thu, 22 Jul 2010, Lukas Renggli wrote: > >>>> 1. #World asClass does not return a class. >>> >>> #classNamed: can solve this. >> >> No, it still returns an instance of PasteUpMorph. > > That's a bug, isn't it? Yeah, strange :-) >>>> 2. We are trying to remove all direct references to the Smalltalk >>>> namespace, this however hardcodes the Smalltalk namespace again. >>> >>> self environment can solve this. >> >> No, what will #asClass return if you have different instances of >> Smalltalk? > > A Class or nil. A random class if there are multiple environments with the same class name? Lukas -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
indeed this is a nice point.
>>> 1. #World asClass does not return a class. >> >> #classNamed: can solve this. > > No, it still returns an instance of PasteUpMorph. > >>> 2. We are trying to remove all direct references to the Smalltalk >>> namespace, this however hardcodes the Smalltalk namespace again. >> >> self environment can solve this. > > No, what will #asClass return if you have different instances of Smalltalk? > > Lukas _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Levente Uzonyi-2
>> >>>> 2. We are trying to remove all direct references to the Smalltalk >>>> namespace, this however hardcodes the Smalltalk namespace again. >>> >>> self environment can solve this. >> >> No, what will #asClass return if you have different instances of Smalltalk? > > A Class or nil. what lukas wants to say is that using asClass you cannot write code that can used on different instances of systemDictionary and this was one of the goal of a lot of cleaning. Stef _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On Thu, 22 Jul 2010, Stéphane Ducasse wrote:
> >>> >>>>> 2. We are trying to remove all direct references to the Smalltalk >>>>> namespace, this however hardcodes the Smalltalk namespace again. >>>> >>>> self environment can solve this. >>> >>> No, what will #asClass return if you have different instances of Smalltalk? >> >> A Class or nil. > > what lukas wants to say is that using asClass you cannot write code that can used > on different instances of systemDictionary and this was one of the goal of a lot of cleaning. will be available, that will be able to solve the class lookup. If not, then how will the following code work?: MyClass new Levente > > Stef > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
> AFAIK there's no usable namespace implementation for Pharo. As soon as one
> will be available, that will be able to solve the class lookup. Right, but a lot of refactorings in the past were made to get rid of the hardcoded references to Smalltalk. Now a method like #asClass just puts it (secretly) back in. Classes should be looked up in the context of a context, such as an existing class. Lukas -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Yes!
>> AFAIK there's no usable namespace implementation for Pharo. As soon as one >> will be available, that will be able to solve the class lookup. I'm not sure about what you imply by class lookup. So far a class is defined in an environment and we can have multiple environment. We did some tests with lukas and the browser nearly worked. > Right, but a lot of refactorings in the past were made to get rid of > the hardcoded references to Smalltalk. Now a method like #asClass just > puts it (secretly) back in. Classes should be looked up in the context > of a context, such as an existing class. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Philippe Marschall-2
I don't know if others already voiced this concern, but what happens
when the symbol does not resolve unambiguously if there are classes with the same "leaf" name in different namespaces? On 7/22/10 6:13 , Philippe Marschall wrote: > Hi > > VAST has an #asClass method on Symbol that does more or less this: > > Symbol>> #asClass > ^ Smalltalk at: self > > This can be quite handy if you want to refer to a class that is not > there a compile time, eg. Metacello. > > Think: > #ConfigurationOfSeaside30 asClass load > > Cheers > Philippe > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |