Message ID | 87h9pvr8uc.fsf@e105548-lin.cambridge.arm.com |
---|---|
State | New |
Headers | show |
On 06/25/2015 11:33 AM, Richard Sandiford wrote: > Jeff Law <law@redhat.com> writes: >> On 06/25/2015 03:49 AM, Richard Biener wrote: >>> On Thu, Jun 25, 2015 at 5:19 AM, Jeff Law <law@redhat.com> wrote: >>>> On 06/24/2015 02:23 AM, Richard Sandiford wrote: >>>>> >>>>> Jeff Law <law@redhat.com> writes: >>>>>> >>>>>> So I'm holding off on approving this one pending further discussion of >>>>>> the use of multiple inheritance for nofree_ptr_hash. >>>>> >>>>> >>>>> I thought that might be controversial. :-) My two main defences are: >>>>> >>>>> 1) This is multiple inheritance of traits classes, which all just have >>>>> static member functions, rather than multiple inheritance of data- >>>>> carrying classes. It's really just a union of two separate groups >>>>> of functions. >>>> >>>> As I was thinking about this during review I almost convinced myself that >>>> multiple inheritance from traits classes ought to be acceptable. >>>> >>>> As you state, they don't carry data and we're just getting a union of their >>>> functions. One could probably even argue that traits classes by their >>>> nature are designed to be composed with other traits and classes. >>>> >>>> I'm (obviously) not as well versed in this stuff as I ought to be, hence my >>>> conservatism. It'd be real helpful if folks with more real world experience >>>> in this space could chime in on the pros/cons if this approach. >>>> >>>> If we do go forward, ISTM updating our coding conventions to codify this >>>> exception to the "avoid MI" would be wise. And my inclination is to go >>>> forward, but let's give other folks a chance to chime in. >>> >>> Yes, I think this is ok. >> Works for me. Richard S., as a follow-up can you update the coding >> conventions, which I think it maintained in the ancient CVS repo for the >> web pages (ping Gerald if you're unfamiliar with it). > > OK, sounds good. How does this look? Looks good. Thanks. jeff
Index: htdocs/codingconventions.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v retrieving revision 1.71 diff -u -r1.71 codingconventions.html --- htdocs/codingconventions.html 9 Jul 2014 00:03:05 -0000 1.71 +++ htdocs/codingconventions.html 25 Jun 2015 17:31:39 -0000 @@ -888,6 +888,9 @@ On the rare occasion that using mulitple inheritance is indeed useful, prepare design rationales in advance, and take special care to make documentation of the entire hierarchy clear. +(In particular, multiple inheritance can be an acceptable way of combining +"traits"-style classes that only contain static member functions. +Its use with data-carrying classes is more problematic.) </p> <p>