Thread overview | |||||
---|---|---|---|---|---|
|
April 12, 2020 Template Inheritance? | ||||
---|---|---|---|---|
| ||||
Today I came across a use case for template inheritance: template Namespace(N) { alias functions = ...; // using getMembers and getOverloads } template Aggregate(A) : Namespace(A) { // aggregate specific stuff, e.g.: alias base = ...; } template Module(M) : Namespace(M) { // module specific stuff } Has this ever been considered? I used a mixin template to get the effect I want... |
April 12, 2020 Re: Template Inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jean-Louis Leroy | On Sunday, 12 April 2020 at 17:12:01 UTC, Jean-Louis Leroy wrote:
> Today I came across a use case for template inheritance:
>
> template Namespace(N)
> {
> alias functions = ...; // using getMembers and getOverloads
> }
>
> template Aggregate(A) : Namespace(A)
> {
> // aggregate specific stuff, e.g.:
> alias base = ...;
> }
>
> template Module(M) : Namespace(M)
> {
> // module specific stuff
> }
>
> Has this ever been considered?
I can't think of a reason to allow this other than (subjectively)
easier code reuse, so I'm not sure this warrants a language feature.
|
April 15, 2020 Re: Template Inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jean-Louis Leroy | On Sunday, 12 April 2020 at 17:12:01 UTC, Jean-Louis Leroy wrote:
> Today I came across a use case for template inheritance:
>
> template Namespace(N)
> {
> alias functions = ...; // using getMembers and getOverloads
> }
>
> template Aggregate(A) : Namespace(A)
> {
> // aggregate specific stuff, e.g.:
> alias base = ...;
> }
>
> template Module(M) : Namespace(M)
> {
> // module specific stuff
> }
>
> Has this ever been considered?
>
> I used a mixin template to get the effect I want...
The only thing I can see this leading to is:
Massive template abuse and even more obscure template error messages.
|
Copyright © 1999-2021 by the D Language Foundation