Challenge: solve this multiple inheritance problem in your favorite language
mw
mingwu at gmail.com
Fri Jun 5 07:11:47 UTC 2020
On Friday, 5 June 2020 at 06:40:06 UTC, Jacob Carlborg wrote:
> It's already possible to do that today:
>
> class Person : NameI, AddrI {
> mixin NameT!Person Name;
> mixin AddrT!Person Addr;
>
> bool equals(Person other) {
> return Name.equals(other) &&
> Addr.equals(other);
> }
> }
Thank you for letting me know.
This alleviates the name clashing problem, but didn't completely
solve it, this renaming is still coarse-grained all-or-none, e.g:
class Visitor {
mixin UKResident UKR;
mixin USResident USR;
}
all the attributes in UKResident.<attr> is rename to UKR.<attr>
and
all the attributes in USResident.<attr> is rename to USR.<attr>
While we want to achieve:
UKR.name === USR.name (have the same storage)
UKR.addr !=== USR.addr (have different storage)
i.e. fine-grained control on each mixin's attribute to be either
joined or separated.
More information about the Digitalmars-d
mailing list