problem mixing Traits and Inheritance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

problem mixing Traits and Inheritance

cdelaunay
Hi,

Here's my problem :
- I have the class NSCollectionStream which define ( for example )  #atEnd
- I have the class NSSubclassOfCollectionStream ( which is a suclass of NSCollectionStream).

When I use a trait in NSSubclassOfCollectionStream that required the method #atEnd, the defintion in NSCollectionStream is not used and the method #atEnd is overridden with :
       atEnd
           self explicitRequirement.

I think we should take care about definitions in superclass, no?


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: problem mixing Traits and Inheritance

Adrian Lienhard
We had a discussion about this on this mailing list some time ago. The  
conclusion, as far as I remember, was that yes, ideally it should  
detect that the method exists in a superclass and hence should not add  
the atEnd method to the subclass in your example. This is not that  
easy to implement, though (if you think through the different cases of  
structural changes that would need to be captured to correctly update  
classes using traits). The simplest solution is to not implement atEnd  
in the trait. Anyway, the information that this method is a  
requirement should be automatically provided by a tool rather than  
being hardcoded by the developer.

Cheers,
Adrian

On Jul 8, 2009, at 11:08 , Cyrille Delaunay wrote:

> Hi,
> Here's my problem :
> - I have the class NSCollectionStream which define ( for example )  
> #atEnd
> - I have the class NSSubclassOfCollectionStream ( which is a suclass  
> of
> NSCollectionStream).
>
> When I use a trait in NSSubclassOfCollectionStream that required the  
> method
> #atEnd, the defintion in NSCollectionStream is not used and the method
> #atEnd is overridden with :
>       atEnd
>           self explicitRequirement.
>
> I think we should take care about definitions in superclass, no?
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: problem mixing Traits and Inheritance

Stéphane Ducasse

On Jul 8, 2009, at 11:31 AM, Adrian Lienhard wrote:

> We had a discussion about this on this mailing list some time ago. The
> conclusion, as far as I remember, was that yes, ideally it should
> detect that the method exists in a superclass and hence should not add
> the atEnd method to the subclass in your example. This is not that
> easy to implement, though (if you think through the different cases of
> structural changes that would need to be captured to correctly update
> classes using traits). The simplest solution is to not implement atEnd
> in the trait. Anyway, the information that this method is a
> requirement should be automatically provided by a tool rather than
> being hardcoded by the developer.

yes after our discussion it was clear that requirement was too static  
for a language like
smalltalk.

>
> Cheers,
> Adrian
>
> On Jul 8, 2009, at 11:08 , Cyrille Delaunay wrote:
>
>> Hi,
>> Here's my problem :
>> - I have the class NSCollectionStream which define ( for example )
>> #atEnd
>> - I have the class NSSubclassOfCollectionStream ( which is a suclass
>> of
>> NSCollectionStream).
>>
>> When I use a trait in NSSubclassOfCollectionStream that required the
>> method
>> #atEnd, the defintion in NSCollectionStream is not used and the  
>> method
>> #atEnd is overridden with :
>>      atEnd
>>          self explicitRequirement.
>>
>> I think we should take care about definitions in superclass, no?
>> _______________________________________________
>> 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
Reply | Threaded
Open this post in threaded view
|

Re: problem mixing Traits and Inheritance

Alexandre Bergel
In reply to this post by cdelaunay
As we agree some times ago, the method

>       atEnd
>            self explicitRequirement.

should not be defined.

Alexandre

On 8 Jul 2009, at 11:08, Cyrille Delaunay wrote:

> Hi,
>
> Here's my problem :
> - I have the class NSCollectionStream which define ( for example )  
> #atEnd
> - I have the class NSSubclassOfCollectionStream ( which is a suclass  
> of NSCollectionStream).
>
> When I use a trait in NSSubclassOfCollectionStream that required the  
> method #atEnd, the defintion in NSCollectionStream is not used and  
> the method #atEnd is overridden with :
>        atEnd
>            self explicitRequirement.
>
> I think we should take care about definitions in superclass, no?
>
> _______________________________________________
> 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