Function pointers/delegates default args were stealth removed?

deadalnix deadalnix at gmail.com
Mon Aug 27 13:29:14 PDT 2012


Le 27/08/2012 00:41, Walter Bright a écrit :
> On 8/26/2012 3:26 PM, Manu wrote:
>> I just updated to 2.60 and found errors throughout my code where function
>> pointers default args no longer work.
>> _Every single project_ I've written in D, 5 projects, don't work anymore,
>> including my projects at work.
>>
>> I found this discussion:
>> http://d.puremagic.com/issues/show_bug.cgi?id=3866
>> It seems the change was just decided and implemented with basically no
>> discussion or argument at all :/
>>
>> My use cases are dynamic linkage, and cross-language integration.
>> I can't manually interact with DLL's containing API's that expect to have
>> default arguments if function pointers no longer support them.
>> Also when receiving foreign language function pointers, they
>> frequently need to
>> have default args too.
>>
>> I also integrate with many C style API's (rendering engines and the
>> like), which
>> involve registration of various callbacks, and lots of those have
>> default args too.
>>
>> I find this particularly surprising, since I recently motivated
>> implementation
>> of new traits which could parse default args from parameter lists, and
>> use that
>> to generation function pointers in templates which auto-magically clone
>> functions parameter lists verbatim, specifically including the default
>> args...
>
> The trouble is that, as 3866 shows, there is no design anyone could come
> up with that worked in a consistent manner. The only consistent way out
> was to make default arguments a characteristic of the declaration, not
> of the type.
>
> The trouble for function pointers, is that any default args would need
> to be part of the type, not the declaration.
>
> I know it broke code (for many others, too), and I'm very sorry about
> that, but I don't see another way out.
>
> (Many uses of default arguments can be replaced with overloaded functions.)
>

That guy just have to rework 5 projects. This is quite a lot of work.

Obviously, that change have to be done. But you can't just impose such a 
change on users. Their agenda isn't synchronized with D's.

D NEED a better versioning scheme, as explained MANY times here already.


More information about the Digitalmars-d mailing list