Then the Java emit code will generate the appropriate one (or more) wrapper methods:
class A
{
static Int f() { return f(3); }
static Int f(Int a) { return a; }
}
Default parameters can be used with constructors, static methods, and instance methods. I have not implemented any error checking to make sure you aren't trying to use invalid expressions (such as accessing a instance variable for a constructor or static method). But since I expect mode defaults will be literals, this should get us pretty far.
brian Sun 8 Jan 2006
I added end-to-end support for method parameter defaults. The Fan syntax is:
The FParam entry in the fcode will contain an fcode buffer for the default expression:
Then the Java emit code will generate the appropriate one (or more) wrapper methods:
Default parameters can be used with constructors, static methods, and instance methods. I have not implemented any error checking to make sure you aren't trying to use invalid expressions (such as accessing a instance variable for a constructor or static method). But since I expect mode defaults will be literals, this should get us pretty far.