April 26, 2012
On 4/26/2012 2:21 AM, Timon Gehr wrote:
> This is a matter of terminology. For example, for 'equal' just exclude the
> default parameters from the comparison. For 'the same' include default
> parameters in the comparison. (therefore, 'the same' implies 'equal')

I think this is torturing the semantics.


> The result of ?: is the type of the two arguments if they are the same, and it
> is the equal type without default arguments if they are not the same.

That's the problem - the selection of arbitrary rules.
April 26, 2012
On 4/26/2012 1:54 AM, Jacob Carlborg wrote:
> On 2012-04-26 05:44, Walter Bright wrote:
>
>> But if we make default arguments solely a part of the function
>> declaration, then function pointers (and delegates) cannot have default
>> arguments. (And maybe this isn't a bad thing?)
>
> Why not?
>

Because a function pointer, and delegate, can exist without a corresponding declaration.
April 26, 2012
On 04/26/2012 08:56 PM, Walter Bright wrote:
> On 4/26/2012 2:21 AM, Timon Gehr wrote:
>> This is a matter of terminology. For example, for 'equal' just exclude
>> the
>> default parameters from the comparison. For 'the same' include default
>> parameters in the comparison. (therefore, 'the same' implies 'equal')
>
> I think this is torturing the semantics.
>
>
>> The result of ?: is the type of the two arguments if they are the
>> same, and it
>> is the equal type without default arguments if they are not the same.
>
> That's the problem - the selection of arbitrary rules.

It is not entirely arbitrary. Anyway, point taken.
April 26, 2012
Le 26/04/2012 20:49, Walter Bright a écrit :
> On 4/26/2012 8:06 AM, Sean Kelly wrote:
>> Sounds to me like you just answered your own question :-)
>
> Pretty much. I posted it here to see if I missed something major. Not
> that that ever happens :-)

Why does default argument should be mangled at all ?
April 26, 2012
I've actually been making fairly extensive use of function/delegate default
args. I was pleasantly surprised when I realised it was possible.
Funnily enough, It's one of those things that I just expected should work
(as I find most things I just expect should work do in fact tend to work in
D), so it seems it was intuitive too at some level.

It would be a shame to see it go, but I wouldn't say it's critical, just very handy. In my case, used in shared interface bindings. Occurs more often than not in some interfaces.

On 26 April 2012 07:00, Jonathan M Davis <jmdavisProg@gmx.com> wrote:

> On Wednesday, April 25, 2012 20:44:07 Walter Bright wrote:
> > A subtle but nasty problem - are default arguments part of the type, or
> part
> > of the declaration?
> >
> >     See http://d.puremagic.com/issues/show_bug.cgi?id=3866
> >
> > Currently, they are both, which leads to the nasty behavior in the bug report.
> >
> > The problem centers around name mangling. If two types mangle the same,
> then
> > they are the same type. But default arguments are not part of the mangled string. Hence the schizophrenic behavior.
> >
> > But if we make default arguments solely a part of the function
> declaration,
> > then function pointers (and delegates) cannot have default arguments.
> (And
> > maybe this isn't a bad thing?)
>
> Can function pointers have default arguments in C? Honestly, it strikes me
> as
> rather bizarre for them to have default arguments. I really don't think
> that
> they buy you much.
>
> If you use the function or delegate immediately after declaring it (as is
> typically the case when they're nested), then you could have just just put
> the
> default argument in the function itself and not have it as a parameter.
> And if
> you're holding on to a function or delegate long term, you're almost
> certainly
> going to be using it generically, in which case I wouldn't expect a default
> argument to make sense there often either.
>
> I'd vote to just disallow default arguments for function pointers and delegates.
>
> - Jonathan M Davis
>


1 2 3 4 5
Next ›   Last »