Function pointers/delegates default args were stealth removed?
Daniel Murphy
yebblies at nospamgmail.com
Tue Aug 28 06:50:51 PDT 2012
"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message
news:mailman.1446.1346070222.31962.digitalmars-d at puremagic.com...
>
> Default arguments just do not make sense with function pointers, because
> they
> don't follow the function pointer, because it's a _pointer_ and has no
> knowledge of what it's pointing to. It's only at the declaration point of
> the
> function that the default argument exists, and that has _nothing_ to do
> with
> the function pointer. You might as well ask a reference of type Object
> what
> the arguments used to construct the derived class that it actually refers
> to
> were as expect a function pointer to have any clue about default arguments
> to
> the function that it points to.
>
> - Jonathan M Davis
Yes, this. I looked into fixing issue 3866 earlier this year, and Kenji's
list sounds very familiar.
It comes down to - function pointers are not function declarations and
therefore can't do everything function declarations do, such as overloading
and default arguments. This is the price of being able to reassign them.
Yes it is possible to make them work the way Manu has been using them, but
the solution is messy and I seriously doubt it's worth it. I agree with
everything Andrei has said about this.
I don't consider putting default arguments back in the type a valid approach
because of the reason above, so that leaves giving function pointer
variables the ability to have default arguments. This seems to me like a
really dumb corner case with the same problems.
More information about the Digitalmars-d
mailing list