Thread overview | |||||
---|---|---|---|---|---|
|
June 20, 2006 Implicit Template Properties - rules change proposal | ||||
---|---|---|---|---|
| ||||
I often find myself creating templates like:
// ----
tempate doSomethingImpl(T) {
template loop(int i) {
....
alias ... loop;
}
alias loop!(0) res;
}
template doSomething(T) {
alias doSomethingImpl!(T).res doSomething;
}
// ----
Clearly the second template is redundant and exists there only to make the usage pattern easier.
My proposal is to change the rules for implicit template properties
from:
"If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation"
to:
"If a template has exactly one *public* member in it, (...) "
Then, the template would look like:
// ----
tempate doSomething(T) {
private template loop(int i) {
....
alias ... loop;
}
alias loop!(0) doSomething;
}
// ----
Opinions ?
--
Tomasz Stachowiak /+ a.k.a. h3r3tic +/
|
June 20, 2006 Re: Implicit Template Properties - rules change proposal | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | > Opinions ?
Yes, it should always be possible to write the things easy. Having the restriction of only one member for such a template seams needless. Your proposal opens another door for easier code with less complexity.
|
June 20, 2006 Re: Implicit Template Properties - rules change proposal | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | Tom S wrote:
> I often find myself creating templates like:
>
> // ----
> tempate doSomethingImpl(T) {
> template loop(int i) {
> ....
> alias ... loop;
> }
>
> alias loop!(0) res;
> }
>
> template doSomething(T) {
> alias doSomethingImpl!(T).res doSomething;
> }
> // ----
>
> Clearly the second template is redundant and exists there only to make the usage pattern easier.
> My proposal is to change the rules for implicit template properties
>
> from:
> "If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation"
>
> to:
> "If a template has exactly one *public* member in it, (...) "
>
>
> Then, the template would look like:
>
> // ----
> tempate doSomething(T) {
> private template loop(int i) {
> ....
> alias ... loop;
> }
>
> alias loop!(0) doSomething;
> }
> // ----
>
> Opinions ?
This would be awesome.
Sean
|
Copyright © 1999-2021 by the D Language Foundation