Summary: Erroneous recursive call in template instantiation
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2011-08-29 
19:49:09 PDT ---
For lack of a better name..

import std.stdio;

enum Method

void Foo(Method method = Method.A)()
    write("dispatch, ");

void Foo(Method method : Method.A)()
    writeln("Foo A");

void Foo(Method method : Method.B)()
    writeln("Foo B");

void main()
    Foo!();           // dispatch, Foo A
    Foo();            // dispatch, Foo A

That works. Now uncomment the first instantiation, the `Foo!()` part and
compile and run. The "dispatch" template instance keeps calling itself until
the stack is blown and the app exits.

What I was trying to do with code like the above was to use template
overloading with type specialization to switch between different types of
drawing methods. The default "dispatch" template is there in case the user
doesn't care which drawing method to use, the dispatch would then instantiate a
specialized template (one specialized for Method.A in this case).

But as you can see, this is buggy territory..

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to