[Issue 8336] Default function parameters ignored by delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 2 08:32:01 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8336


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jmdavisProg at gmx.com
         Resolution|                            |DUPLICATE


--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-07-02 08:34:37 PDT ---
Given how default arguments work, they make _no_ sense for either function
pointers or delegates. All that happens with a default argument is that when
you call the function, if you don't provide a value for the parameter with a
default argument, the default argument is inserted for you. It's not part of
the function's type. It doesn't result in multiple functions being declared.
So, if you do

void foo(int value = 5) {...}
auto funcPtr = &foo;

you've lost the information about the default argument. You simply have

void function(int value) funcPtr;

You could reassign it like so

void bar(int number) {... }
funcPtr = &bar;

because the types are identical. The default argument has zero effect on the
type. The situation does not change if you're dealing with a delegate rather
than a function pointer. Function pointers and delegates just don't have
anything to do with default arguments.

There's further discussion on this in bug# 4208, which was ultimately closed as
a duplicate of bug# 3646 - both of which relate to stuff compiling when it
shouldn't due to issues with default arguments.

*** This issue has been marked as a duplicate of issue 3646 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list