Default argument values

Nick Sabalausky a at a.a
Thu May 20 14:08:59 PDT 2010


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:ht47l8$gfj$1 at digitalmars.com...
> This page talks about default function argument values in C#4:
> http://www.lostechies.com/blogs/jimmy_bogard/archive/2010/05/18/caveats-of-c-4-0-optional-parameters.aspx
>
>
> Near the end it says:
>
>>If we change the value of the optional argument from 0 to 1, we have to 
>>recompile all calling code for the calling code to get the updated value! 
>>For folks shipping assemblies for a living, this means that optional 
>>argument values don't version well, as callers have to recompile.  When I 
>>used to work for a company whose product included a DLL, we avoided 
>>optional method arguments for just this reason. It's not a reason not to 
>>use optional arguments, but it's important to understand how they work so 
>>that you don't run into headaches later.<
>
> D too copies the default value at the calling point. Looking at this from 
> the eyes of a Python programmer this looks like a dirty hack.
> This can be a cause of problems in D dlls too, I am not sure.
>

I dunno, a caller might rely on a default value being what it was when they 
had compiled it. Forcing them to get a new version of the library and 
recompile increases the chance that they're notice that the new value is 
different, either via a "this has changed" in the docs, or when they run it 
after recompiling with the new version of the library. Not sure if my 
argument really holds up or not, but just a thought. 




More information about the Digitalmars-d mailing list