April 19, 2013
On Friday, 19 April 2013 at 19:06:39 UTC, Walter Bright wrote:
> On 4/19/2013 6:55 AM, deadalnix wrote:
>> As of for 2 I'd rather have a standard way to have attribute binding to the
>> return type or the declaration. This is a recurring problem, and auto is simply
>> one instance of it.
>
> I'm not understanding it being a recurring problem. There is a recurring misunderstanding that attributes are applying to a type when they are defined as applying to the declaration.
>

What is type of an impure function that return a pure, extern(C) function n D ?
April 19, 2013
On 04/19/2013 09:34 PM, deadalnix wrote:
> On Friday, 19 April 2013 at 19:06:39 UTC, Walter Bright wrote:
>> On 4/19/2013 6:55 AM, deadalnix wrote:
>>> As of for 2 I'd rather have a standard way to have attribute binding
>>> to the
>>> return type or the declaration. This is a recurring problem, and auto
>>> is simply
>>> one instance of it.
>>
>> I'm not understanding it being a recurring problem. There is a
>> recurring misunderstanding that attributes are applying to a type when
>> they are defined as applying to the declaration.
>>
>
> What is type of an impure function that return a pure, extern(C)
> function n D ?

Currently, it exists, yet cannot be named, and the formatted output of the compiler is wrong.

alias extern(C) int function()pure P;
P foo(){ return null; }

pragma(msg, typeof(&foo));

=> "extern (C) int function() pure function()"
April 20, 2013
On 4/19/2013 12:34 PM, deadalnix wrote:
> On Friday, 19 April 2013 at 19:06:39 UTC, Walter Bright wrote:
>> On 4/19/2013 6:55 AM, deadalnix wrote:
>>> As of for 2 I'd rather have a standard way to have attribute binding to the
>>> return type or the declaration. This is a recurring problem, and auto is simply
>>> one instance of it.
>>
>> I'm not understanding it being a recurring problem. There is a recurring
>> misunderstanding that attributes are applying to a type when they are defined
>> as applying to the declaration.
>>
>
> What is type of an impure function that return a pure, extern(C) function n D ?

A function foo:

extern(C) int function()pure foo() { return null; }

A type fp:

alias extern(C) int function()pure function() fp;
April 20, 2013
On Saturday, 20 April 2013 at 00:03:36 UTC, Walter Bright wrote:
> A function foo:
>
> extern(C) int function()pure foo() { return null; }
>

That is not it as foo is extern(C).

> A type fp:
>
> alias extern(C) int function()pure function() fp;

Same here.

In general we lack a mechanism to choose what an attribute bind to.
April 20, 2013
On Friday, 19 April 2013 at 22:16:43 UTC, Timon Gehr wrote:
> Currently, it exists, yet cannot be named, and the formatted output of the compiler is wrong.
>
> alias extern(C) int function()pure P;
> P foo(){ return null; }
>
> pragma(msg, typeof(&foo));
>
> => "extern (C) int function() pure function()"

Yes you have to use a alias to do this kind of thing. But some time, you can't alias (in case of inference for instance) and so can't choose what attribute bind to.
April 20, 2013
On 4/19/2013 11:08 PM, deadalnix wrote:
> On Saturday, 20 April 2013 at 00:03:36 UTC, Walter Bright wrote:
>> A function foo:
>>
>> extern(C) int function()pure foo() { return null; }
>>
>
> That is not it as foo is extern(C).

That is correct. I was thinking about the pure. The extern(C) can be done in a two step process, as Timon showed.


> In general we lack a mechanism to choose what an attribute bind to.

No, we don't. The attribute binds to the declaration.

BTW, in C++ also you gotta do the extern "C" as a two step process to attach it to a function type.
April 20, 2013
On 4/19/2013 11:12 PM, deadalnix wrote:
> But some time, you can't
> alias (in case of inference for instance) and so can't choose what attribute
> bind to.

Example, please.
April 20, 2013
On Saturday, 20 April 2013 at 06:24:36 UTC, Walter Bright wrote:
>> In general we lack a mechanism to choose what an attribute bind to.
>
> No, we don't. The attribute binds to the declaration.
>

In general we lack a mechanism to choose what direction we turn to.
No, we don't. We always turn to the right.
April 20, 2013
On Saturday, 20 April 2013 at 06:32:50 UTC, deadalnix wrote:
> On Saturday, 20 April 2013 at 06:24:36 UTC, Walter Bright wrote:
>>> In general we lack a mechanism to choose what an attribute bind to.
>>
>> No, we don't. The attribute binds to the declaration.
>>
>
> In general we lack a mechanism to choose what direction we turn to.
> No, we don't. We always turn to the right.

I am quite sure Walter has meant that linkage attribute was not supposed to be tied to a type by design. If you want to use it, you need a symbol (==declaration) and there can be only one at a time.

April 20, 2013
On Saturday, 20 April 2013 at 07:03:55 UTC, Dicebot wrote:
> On Saturday, 20 April 2013 at 06:32:50 UTC, deadalnix wrote:
>> On Saturday, 20 April 2013 at 06:24:36 UTC, Walter Bright wrote:
>>>> In general we lack a mechanism to choose what an attribute bind to.
>>>
>>> No, we don't. The attribute binds to the declaration.
>>>
>>
>> In general we lack a mechanism to choose what direction we turn to.
>> No, we don't. We always turn to the right.
>
> I am quite sure Walter has meant that linkage attribute was not supposed to be tied to a type by design. If you want to use it, you need a symbol (==declaration) and there can be only one at a time.

You don't need a symbol. They also control the ABI, and this isn't always related to a specific symbol.