DIP27 available for destruction

deadalnix deadalnix at gmail.com
Wed Feb 27 19:16:16 PST 2013


On Wednesday, 27 February 2013 at 17:30:16 UTC, Andrej Mitrovic 
wrote:
> On 2/27/13, deadalnix <deadalnix at gmail.com> wrote:
>> That is fallacy.
>
> void func(T...)(T args) { }
>
> int foo() { return 1; }
> float bar() { return 2.0; }
>
> void main()
> {
>     func(foo, bar);  // ???
> }
>
> What will this do? If address-of on functions is banned then 
> this must
> pass functions by default, and not their return types. Which is 
> a
> complete change to what it does now.
>

Yes it is.

> So now you have to carefully inspect every function call 
> because you
> don't know whether you're passing a pointer to a function or 
> you're
> invoking the function and passing the return type.
>

This ambiguity is what the DIP intend to solve. Here foo can 
refers to different entity types depending on the context. When 
you do &foo, you refers to function in the C meaning of the term, 
when you do foo, you refers to function call.

> How on earth does this simplify anything and justify code 
> breakage?

It remove an entity type from the language, so remove an entire 
line and column in the feature matrix, so it simplify its 
definition, its implementation and get rid of a whole class of 
corner cases. It reduces the number of cases you have to account 
for in generic code as well. It remove ambiguities that currently 
exists on the usage of unary & operator. It makes D more friendly 
for functional style of code.


More information about the Digitalmars-d mailing list