[Issue 1820] New: default template parameters cannot be omitted
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Feb  7 15:11:19 PST 2008
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=1820
           Summary: default template parameters cannot be omitted
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: andrei at metalanguage.com
The following code compiles and runs as expected:
import std.stdio;
template wyda(string pred = ``)
{
    void wyda(int x) { writeln(pred, " ", x); }
}
void main()
{
    wyda(3);
    wyda!("a")(4);
}
However, the following equivalent code does not:
import std.stdio;
template wyda(string pred = ``)
{
    static if (true)
        void wyda(int x) { writeln(pred, " ", x); }
}
void main()
{
    wyda(3);
    wyda!("a")(4);
}
The proposed solution is to get rid to the maximum extent possible of the
requirements for the noisy "!()" syntax. If a template name is specified
without the "!", then it should simply assume "!()" followed.
Andrei
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list