April 07, 2007 Recursive mixins problem | ||||
---|---|---|---|---|
| ||||
Why recursive mixins are disallowed? template Call(A...) { static if (A.length > 0) { void call(A[0] fn) { } mixin Call!(A[1..$]); } } class Caller(A...) { mixin Call!(A); } void main() { auto caller = new Caller!(int delegate(), char[] delegate()); } hello.d(15): mixin hello.Caller!(int delegate(),char[] delegate()).Caller.Call!(int delegate(),char[] delegate()).Call!(char[] delegate()).Call!() recursive mixin instantiation hello.d(26): template instance hello.Caller!(int delegate(),char[] delegate()) error instantiating |
April 10, 2007 Re: Recursive mixins problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | On Sat, 07 Apr 2007 16:55:16 +0300, Max Samukha <samukha@voliacable.com> wrote:
>Why recursive mixins are disallowed?
>
>template Call(A...)
>{
> static if (A.length > 0)
> {
> void call(A[0] fn)
> {
> }
>
> mixin Call!(A[1..$]);
> }
>}
>
>class Caller(A...)
>{
> mixin Call!(A);
>}
>
>void main()
>{
> auto caller = new Caller!(int delegate(), char[] delegate());
>}
>
>hello.d(15): mixin hello.Caller!(int delegate(),char[]
>delegate()).Caller.Call!(int delegate(),char[]
>delegate()).Call!(char[] delegate()).Call!() recursive mixin
>instantiation
>hello.d(26): template instance hello.Caller!(int delegate(),char[]
>delegate()) error instantiating
>
>
>
>
>
In the example above, char[] delegate() should be replaced with
something like int delegate(char[]) for proper function overloading.
Anyway, the problem remains. Is it a bug or temporary restriction? If not, should a note be added to the specs?
|
Copyright © 1999-2021 by the D Language Foundation