Private default function arguments

Robert Clipsham robert at octarineparrot.com
Sat Jan 16 05:53:22 PST 2010


On 15/01/10 08:25, bearophile wrote:
> int foo3(int x, private int depth=0) {
>    ...
>    foo3(x+1); // OK
>    foo3(x, depth + 1); // OK
>    ...
> }
> void main() {
>    int r = foo3(5); // OK
>    int r = foo3(5, 1); // Error
>    int r = foo3(5, 0); // Error
> }

Does this not achieve the same effect? (OK, the syntax is a bit more 
verbose, but it'd do the trick?)

----
int foo3(int x)
{
    static int depth = 0;
    foo3( x + 1 );
    depth++;
    foo3( x );
}
----



More information about the Digitalmars-d mailing list