mixin bug?
sldkf via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 12 16:48:54 PDT 2016
On Friday, 12 August 2016 at 23:14:23 UTC, Engine Machine wrote:
> On Friday, 12 August 2016 at 15:35:50 UTC, sldkf wrote:
>> On Friday, 12 August 2016 at 02:09:21 UTC, Engine Machine
>> wrote:
>>> On Thursday, 11 August 2016 at 21:25:20 UTC, sldkf wrote:
>>>> On Thursday, 11 August 2016 at 20:27:01 UTC, Engine Machine
>
> This is not the solution to the original problem.
>
> template X(T)
> {
> int _len = 0;
> int Length() { return _len; }
> int length(this T)() { return (cast(T)this).Length(); }
> }
>
> template Y(T)
> {
> mixin X!T;
> int Length() { return 3; }
> }
>
>
> Then calling length returns 0, while calling Length returns 3.
> But we obviously want length to "follow" Length, yet it doesn't
> due to D resolving length in X before it is mixed in Y!T.
No "length" returns 3.
https://ideone.com/T8HjZl
Really, it's there, in front of your eyes.
More information about the Digitalmars-d-learn
mailing list