class Product
: public ValuableCollectionDescendantContract<Product, std::set<Variable>>
{
using base = ValuableCollectionDescendantContract<Product, std::set<Variable>>;
using cont = std::set<Variable>;
look and feel better, deduplication >>>>
class Product
: public ValuableCollectionDescendantContract<Product, std::set<Variable>>
{
using base::cont;
Obvious need to access base classes often.
Furthermore, C++ has multiple inheritance, so now you have to decide which base you're talking about. Now, that could actually be an interesting and useful construct: `base<I>` would resolve to the `I`th base class of the class in question. And reflection wouldn't be as good in this case, since a keyword (or whatever) would be able to use the current context to know which class to get the base class of. Reflection-based mechanisms would require that we specify which class we're talking about.
Furthermore, C++ has multiple inheritance, so now you have to decide which base you're talking about. Now, that could actually be an interesting and useful construct: `base<I>` would resolve to the `I`th base class of the class in question. And reflection wouldn't be as good in this case, since a keyword (or whatever) would be able to use the current context to know which class to get the base class of. Reflection-based mechanisms would require that we specify which class we're talking about.Python supports multiple inheritance too and I'd suggest you clone their super() function rather than invent anything new.
Python supports multiple inheritance too and I'd suggest you clone their super() function rather than invent anything new.Oh dear. Literally anything would be better than Python's super() function.Python invents a sort of linearization of the multiple-inheritance tree (the MRO) so that you can manually call super-class __init__ routines (or not) as you choose; i.e., Python does not have the concept of "constructor" as we understand it in C++. It's more like Objective-C's init routines.
In my experience it's basically impossible to use correctly; if you're doing multiple inheritance in Python you're probably doing something wrong whether you're aware of it or not.(In Python 2 super() requires repeating the name of your own class anyway, where repetition of class names was the original problem OP wanted to solve. But I see that the repetition has been dropped from Python 3 — cool! This tutorial seems fair and balanced to me, and covers the syntax in both dialects of Python.)
This blog post points out something I'd never consciously considered before: Python has no non-virtual inheritance (I think?).
Anyway, I don't think there's any problem to be solved here. Certainly I don't think C++ should introduce any special syntax for the "I'th base class." If you want something like that, you probably want Herb Sutter's metaclasses (or better) anyway.
Hi Arthur,
Making template of a class is deduplication. But it makes compilation much longer. And allows unproper use unless we enforce specific base by static assert.
A compilation error message may be shown in case of any collisions.
От: Arthur O'Dwyer
Отправлено: понедельник, 2 октября 2017 г. в 08:31
Кому: ISO C++ Standard - Future Proposals
Копия: sergeik...@gmail.com
Тема: Re: base and self built-in keywords
Python supports multiple inheritance too and I'd suggest you clone their super() function rather than invent anything new.Oh dear. Literally anything would be better than Python's super() function.Python invents a sort of linearization of the multiple-inheritance tree (the MRO) so that you can manually call super-class __init__ routines (or not) as you choose; i.e., Python does not have the concept of "constructor" as we understand it in C++. It's more like Objective-C's init routines.A more accurate explanation is that super() would return the native vtable for the selected inherited class.
Python's really great. Such a deep well of evil power available to the programmer.
This blog post points out something I'd never consciously considered before: Python has no non-virtual inheritance (I think?).More that virtual inheritance is the default for all member functions. You need to explicitly ask to call a non-virtualised implementation, which is via super() actually.