DIP23 Counter Proposal

deadalnix deadalnix at gmail.com
Tue Feb 5 21:12:45 PST 2013


On Wednesday, 6 February 2013 at 03:43:28 UTC, Timon Gehr wrote:
>> 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?
>

2. I see no point in not making foo a first class function value.
Not having it does complicate things for no benefit. Any
complication should be properly motivated.

This does not imply that optional () should be removed, as it is
a mostly orthogonal problems (as scala shows).

1. As of backward compat, & can be kept and follow the usual
deprecation process.

>> 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.

Well the thing that a function CANNOT be used before template 
parameter (so function will be removed from overload set and only 
template will remains).


More information about the Digitalmars-d mailing list