DIP23 Counter Proposal
Timon Gehr
timon.gehr at gmx.ch
Thu Feb 7 06:37:52 PST 2013
On 02/07/2013 02:56 PM, Steven Schveighoffer wrote:
> On Wed, 06 Feb 2013 21:53:25 -0500, deadalnix <deadalnix at gmail.com> wrote:
>
>> On Wednesday, 6 February 2013 at 21:30:10 UTC, Timon Gehr wrote:
>>>> &(fun, fun)
>>>>
>>>
>>> Agh, comma strikes again. It should be handled analogous to the
>>> ternary expression. i.e. the expression above evaluates fun and then
>>> returns the function pointer. The DIP now states this. (the second
>>> fun is in address-taken position.) This is in agreement to how lvalue
>>> positions propagate into comma expressions.
>>>
>>
>> Adding more special cases are not gonna create a good DIP.
>
> I don't they are so much a special case, as they are a clarification.
>
> The two "exceptions" are simply explaining that because ternary operator
> and comma operators evaluate to an lvalue, it is equivalent to putting
> the & on the resulting lvalue.
>
> -Steve
Exactly. Those operators already have this behaviour in other contexts.
OT: One of my favourite comma/ternary-isms is the following:
import std.typecons : tuple;
void foo(int x){}
void main(){
int x;
foo((x++,tuple.expand),x,(x++,tuple.expand));
foo(true?tuple.expand:tuple.expand,x,);
}
I think it is valid code. :-)
DMD cannot handle it though.
More information about the Digitalmars-d
mailing list