Private default function arguments

retard re at tard.com.invalid
Fri Jan 15 03:47:26 PST 2010


Fri, 15 Jan 2010 04:38:19 -0500, bearophile wrote:

> Clemens:
> 
>> void foo(int x)
>> {
>>     void fooImpl(int x, int depth);
>>     {
>>         // ...
>>     }
>> 
>>     fooImpl(x, 0);
>> }
> 
> OK, I'll use a static nested function then, it's not as clean as adding
> a "private" attribute, but probably there's not enough need to add other
> features to the language:

I don't know what's your definition of clean, but you're twisting the 
semantics of a mostly clean part of the language. Functions have long 
traditions and roots in lambda calculus. Default arguments are a small 
modification on top of that. But the private modifier is something that 
comes from the object oriented approach.

> The compiler probably takes care of always optimize the extra function
> call away.

Of course, that's a trivial optimization.



More information about the Digitalmars-d mailing list