Hi!
Just wondering. What about redefining new into: -=-=-=-=-=-=-=-=-=-=-=-= Behavior>>new "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. ^ self basicNew initialize -=-=-=-=-=-=-=-=-=-=-=-= This may break a lot of code however. Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
And it will also require modifying the Pharo by Example book that says
that there's nothing wrong with instantiating abstract classes and that there is no *abstract* class marker in this sense, only abstract methods. So, why would try to convert Pharo to another language ? Stanislav Paskalev On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: > Hi! > > Just wondering. What about redefining new into: > -=-=-=-=-=-=-=-=-=-=-=-= > Behavior>>new > "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." > self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. > ^ self basicNew initialize > -=-=-=-=-=-=-=-=-=-=-=-= > > This may break a lot of code however. > > Cheers, > Alexandre > -- > _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: > Alexandre Bergel http://www.bergel.eu > ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. > > > > > > > _______________________________________________ > 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 |
Yes please don't add that. It is alreday pain enough to get
complicated objects setup in the right oder with the #initialize always being called (ok it is easy to work around and in many cases it is just fine, but you need to be aware of it). Lukas On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: > And it will also require modifying the Pharo by Example book that says > that there's nothing wrong with instantiating abstract classes and > that there is no *abstract* class marker in this sense, only abstract > methods. > > So, why would try to convert Pharo to another language ? > > Stanislav Paskalev > > > On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >> Hi! >> >> Just wondering. What about redefining new into: >> -=-=-=-=-=-=-=-=-=-=-=-= >> Behavior>>new >> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >> ^ self basicNew initialize >> -=-=-=-=-=-=-=-=-=-=-=-= >> >> This may break a lot of code however. >> >> Cheers, >> Alexandre >> -- >> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >> Alexandre Bergel http://www.bergel.eu >> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >> >> >> >> >> >> >> _______________________________________________ >> 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 |
> Yes please don't add that.
This is not my intention. But I just discovered some bugs in my test because I instantiated a class that shouldn't be instantiated since it is abstract. If now we close our eyes and dream about a clean oo language. Will forbidding to instantiate an abstract class a wished feature? Cheers, Alexandre > > On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: >> And it will also require modifying the Pharo by Example book that says >> that there's nothing wrong with instantiating abstract classes and >> that there is no *abstract* class marker in this sense, only abstract >> methods. >> >> So, why would try to convert Pharo to another language ? >> >> Stanislav Paskalev >> >> >> On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >>> Hi! >>> >>> Just wondering. What about redefining new into: >>> -=-=-=-=-=-=-=-=-=-=-=-= >>> Behavior>>new >>> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >>> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >>> ^ self basicNew initialize >>> -=-=-=-=-=-=-=-=-=-=-=-= >>> >>> This may break a lot of code however. >>> >>> Cheers, >>> Alexandre >>> -- >>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >>> Alexandre Bergel http://www.bergel.eu >>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> 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 -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On Wed, Aug 11, 2010 at 3:23 PM, Alexandre Bergel <[hidden email]> wrote:
I am also against of this change. We should continue to have flexible language and not to convert this in Java. In addition, I MAY want to instantiate Abstract classes. Sometime you are doing prototypes, or TDD, and you want to instantiate an object of an abstract class. Even if you have a subclassResponsability. I don't care. Maybe I am not testing that right now, nor showing that to my client. I think the correct way to detect your kind of problems is with Lint. If it is not already done, maybe it could be added. Cheers Mariano Cheers, _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Alexandre Bergel
On 11.08.2010, at 15:23, Alexandre Bergel wrote: >> Yes please don't add that. > > This is not my intention. But I just discovered some bugs in my test because I instantiated a class that shouldn't be instantiated since it is abstract. > If now we close our eyes and dream about a clean oo language. Will forbidding to instantiate an abstract class a wished feature? > Ok, I'm going slightly off-topic here. But what makes me wonder is that it is Behavior>>isAbstractClass and not Class>>isAbstractClass And wouldn't it than be Class>>basicNew self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. ^ super basicNew if you want to avoid abstract classes being instantiated? Not to forget basicNew: Just a question. Norbert >> >> On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: >>> And it will also require modifying the Pharo by Example book that says >>> that there's nothing wrong with instantiating abstract classes and >>> that there is no *abstract* class marker in this sense, only abstract >>> methods. >>> >>> So, why would try to convert Pharo to another language ? >>> >>> Stanislav Paskalev >>> >>> >>> On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >>>> Hi! >>>> >>>> Just wondering. What about redefining new into: >>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>> Behavior>>new >>>> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >>>> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >>>> ^ self basicNew initialize >>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>> >>>> This may break a lot of code however. >>>> >>>> Cheers, >>>> Alexandre >>>> -- >>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >>>> Alexandre Bergel http://www.bergel.eu >>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >>>> >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 > > -- > _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: > Alexandre Bergel http://www.bergel.eu > ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. > > > > > > > _______________________________________________ > 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 Mariano Martinez Peck
On Wednesday, August 11, 2010, Mariano Martinez Peck
<[hidden email]> wrote: > > > On Wed, Aug 11, 2010 at 3:23 PM, Alexandre Bergel <[hidden email]> wrote: > >> Yes please don't add that. > > This is not my intention. But I just discovered some bugs in my test because I instantiated a class that shouldn't be instantiated since it is abstract. > If now we close our eyes and dream about a clean oo language. Will forbidding to instantiate an abstract class a wished feature? > > > I am also against of this change. We should continue to have flexible language and not to convert this in Java. In addition, I MAY want to instantiate Abstract classes. > Sometime you are doing prototypes, or TDD, and you want to instantiate an object of an abstract class. Even if you have a subclassResponsability. I don't care. Maybe I am not testing that right now, nor showing that to my client. > > I think the correct way to detect your kind of problems is with Lint. If it is not already done, maybe it could be added. There is a rule that checks for that, I think it is called "refers to abstract class". I don't have an image at hand to verify. It could be extended to take a declaration like #isAbstractClass into account. Lukaz > > Cheers > > Mariano > > > Cheers, > Alexandre > >> >> On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: >>> And it will also require modifying the Pharo by Example book that says >>> that there's nothing wrong with instantiating abstract classes and >>> that there is no *abstract* class marker in this sense, only abstract >>> methods. >>> >>> So, why would try to convert Pharo to another language ? >>> >>> Stanislav Paskalev >>> >>> >>> On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >>>> Hi! >>>> >>>> Just wondering. What about redefining new into: >>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>> Behavior>>new >>>> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >>>> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >>>> ^ self basicNew initialize >>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>> >>>> This may break a lot of code however. >>>> >>>> Cheers, >>>> Alexandre >>>> -- >>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >>>> Alexandre Bergel http://www.bergel.eu >>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >>>> >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 > > -- > _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: > Alexandre Bergel http://www.bergel.eu > ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. > > > > > > > _______________________________________________ > 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 NorbertHartl
> Ok, I'm going slightly off-topic here. But what makes me wonder is that it is
> > Behavior>>isAbstractClass > > and not > > Class>>isAbstractClass Good point. Someone else agree with this change? If yes, I do it. > And wouldn't it than be > > Class>>basicNew > self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. > ^ super basicNew > > if you want to avoid abstract classes being instantiated? Not to forget basicNew: The whole mailing list will express its wrath if you do this. > Just a question. Ah, it was just a question. Fine then :-) Alexandre > > Norbert > >>> >>> On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: >>>> And it will also require modifying the Pharo by Example book that says >>>> that there's nothing wrong with instantiating abstract classes and >>>> that there is no *abstract* class marker in this sense, only abstract >>>> methods. >>>> >>>> So, why would try to convert Pharo to another language ? >>>> >>>> Stanislav Paskalev >>>> >>>> >>>> On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >>>>> Hi! >>>>> >>>>> Just wondering. What about redefining new into: >>>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>>> Behavior>>new >>>>> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >>>>> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >>>>> ^ self basicNew initialize >>>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>>> >>>>> This may break a lot of code however. >>>>> >>>>> Cheers, >>>>> Alexandre >>>>> -- >>>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >>>>> Alexandre Bergel http://www.bergel.eu >>>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 >> >> -- >> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >> Alexandre Bergel http://www.bergel.eu >> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >> >> >> >> >> >> >> _______________________________________________ >> 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 -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by NorbertHartl
> Ok, I'm going slightly off-topic here. But what makes me wonder is that it is
> > Behavior>>isAbstractClass > > and not > > Class>>isAbstractClass SLICE-Issue-1383-isAbstractClass-Alexandre_Bergel.1 in the inbox http://code.google.com/p/pharo/issues/detail?id=1383 Cheers, Alexandre > >>> >>> On Wednesday, August 11, 2010, Stanislav Paskalev <[hidden email]> wrote: >>>> And it will also require modifying the Pharo by Example book that says >>>> that there's nothing wrong with instantiating abstract classes and >>>> that there is no *abstract* class marker in this sense, only abstract >>>> methods. >>>> >>>> So, why would try to convert Pharo to another language ? >>>> >>>> Stanislav Paskalev >>>> >>>> >>>> On Wed, Aug 11, 2010 at 3:43 PM, Alexandre Bergel <[hidden email]> wrote: >>>>> Hi! >>>>> >>>>> Just wondering. What about redefining new into: >>>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>>> Behavior>>new >>>>> "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." >>>>> self isAbstractClass ifTrue: [ self error: 'An abstract class cannot be instantiated' ]. >>>>> ^ self basicNew initialize >>>>> -=-=-=-=-=-=-=-=-=-=-=-= >>>>> >>>>> This may break a lot of code however. >>>>> >>>>> Cheers, >>>>> Alexandre >>>>> -- >>>>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >>>>> Alexandre Bergel http://www.bergel.eu >>>>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 >> >> -- >> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: >> Alexandre Bergel http://www.bergel.eu >> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. >> >> >> >> >> >> >> _______________________________________________ >> 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 -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |