Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 04, 2018 Eponymous template member from a template mixin | ||||
---|---|---|---|---|
| ||||
This doesn't work: template A() { void B() {}; } template B() { mixin A!(); } void main() { B!()(); } Is this intentional? |
August 04, 2018 Re: Eponymous template member from a template mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | On 8/4/18 4:10 PM, Yuxuan Shui wrote:
> This doesn't work:
>
> template A() {
> void B() {};
> }
> template B() {
> mixin A!();
> }
> void main() {
> B!()();
> }
>
> Is this intentional?
I believe mixin templates introduce a new symbol namespace to a degree. I doubt you would be able to do something like this.
-Steve
|
August 04, 2018 Re: Eponymous template member from a template mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Saturday, August 04, 2018 17:10:32 Steven Schveighoffer via Digitalmars- d-learn wrote:
> On 8/4/18 4:10 PM, Yuxuan Shui wrote:
> > This doesn't work:
> >
> > template A() {
> >
> > void B() {};
> >
> > }
> > template B() {
> >
> > mixin A!();
> >
> > }
> > void main() {
> >
> > B!()();
> >
> > }
> >
> > Is this intentional?
>
> I believe mixin templates introduce a new symbol namespace to a degree. I doubt you would be able to do something like this.
A prime example of this is how you can't introduce function overloads with a template mixin.
- Jonathan M Davis
|
August 05, 2018 Re: Eponymous template member from a template mixin | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Saturday, 4 August 2018 at 21:10:32 UTC, Steven Schveighoffer wrote:
> On 8/4/18 4:10 PM, Yuxuan Shui wrote:
>> This doesn't work:
>>
>> template A() {
>> void B() {};
>> }
>> template B() {
>> mixin A!();
>> }
>> void main() {
>> B!()();
>> }
>>
>> Is this intentional?
>
> I believe mixin templates introduce a new symbol namespace to a degree. I doubt you would be able to do something like this.
>
> -Steve
What is the rational behind this?
|
Copyright © 1999-2021 by the D Language Foundation