DIP23 Counter Proposal

Timon Gehr timon.gehr at gmx.ch
Tue Feb 5 19:43:27 PST 2013


On 02/06/2013 04:31 AM, deadalnix wrote:
> On Wednesday, 6 February 2013 at 00:39:55 UTC, Timon Gehr wrote:
>> As my posts in the DIP23 thread have been left unanswered, I have
>> prepared a counter proposal for DIP23 during the last hour.
>>
>> Everything DIP23 addresses is specified in the two short sub-sections
>> "Optional parens" and "@property: basic design".
>>
>> Those in favour of what was called "semantic rewrites" in the DIP23
>> thread should probably read on further.
>>
>> All parts of this proposal are independent of DIP24 (which Andrei is
>> preparing).
>>
>> http://wiki.dlang.org/DIP23_Counter_Proposal
>>
>> There are almost no examples yet, but in case it is not clear how some
>> case would be handled, feel free to ask.
>>
>
> I have to spend more time on the @property part.
>
> For the optional () part, I want to raise concern about point 2 (the
> others make sense).
>
> In all other points, foo is either a call to function foo or the
> function foo itself. In point 2, we introduce a 3rd meaning of foo,
> identical to weird stuff we have in C/C++ (as we obviously aren't taking
> the address either of the function or of its result when executed). This
> object is an error of C and C++ we must get rid of.
>

1. This would break a lot of code.
2. How to get a first-class function value (function pointer, delegate) 
from a function name otherwise?

> Point 1, 4 and 5 make sense.
>
> Point 3 is nonsensial if we want to really be rigorous as :
> returnType foo(TemplateArgs)(args) {}
>
> is equivalent to
>
> template foo(TemplateArgs) {
>      returnType foo(args) {}
> }
>
> In this case foo is a template,

Yes, a function template. Note that functions overload against function 
templates.

> not a function. foo!args is the function
> hen eponymous trick is used.

I think you misunderstand.

If we have eg:

void foo(){ return 2; }
void foo(int x)(){ return 2; }

then we want:

static assert(foo!2==2);

Without rule 3, the code would be rewritten to

static assert(foo()!2==2);

And this would fail.















More information about the Digitalmars-d mailing list