Jump to page: 1 25  
Page
Thread overview
Local functions infer attributes?
Sep 28, 2014
Manu
Sep 28, 2014
deadalnix
Sep 28, 2014
Walter Bright
Sep 28, 2014
deadalnix
Sep 28, 2014
Walter Bright
Sep 28, 2014
deadalnix
Sep 28, 2014
Walter Bright
Sep 28, 2014
bearophile
Sep 28, 2014
Walter Bright
Sep 30, 2014
Trass3r
Sep 30, 2014
deadalnix
Sep 29, 2014
Manu
Sep 29, 2014
Walter Bright
Sep 29, 2014
Manu
Sep 29, 2014
Walter Bright
Sep 29, 2014
Timon Gehr
Sep 29, 2014
Walter Bright
Sep 30, 2014
Daniel N
Sep 30, 2014
Manu
Sep 30, 2014
deadalnix
Sep 30, 2014
Daniel N
Sep 30, 2014
John Colvin
Sep 30, 2014
John Colvin
Sep 29, 2014
Manu
Oct 11, 2014
Daniel N
Sep 29, 2014
deadalnix
Sep 30, 2014
Manu
Sep 30, 2014
deadalnix
Sep 30, 2014
Manu
Sep 30, 2014
Manu
Sep 30, 2014
bearophile
Sep 30, 2014
Manu
Sep 30, 2014
bearophile
Sep 30, 2014
ixid
Sep 30, 2014
Sad panda
Sep 30, 2014
bearophile
Sep 30, 2014
bachmeier
Sep 30, 2014
Walter Bright
Sep 30, 2014
Wyatt
September 28, 2014
void f() pure nothrow @nogc
{
   void localFunc()
   {
   }

   localFunc();
}

Complains because localFunc is not @nogc or nothrow. Doesn't complain about pure though.

Is it reasonable to say that the scope of the outer function is nothrow+@nogc, and therefore everything declared within should also be so?
September 28, 2014
On Sunday, 28 September 2014 at 02:42:29 UTC, Manu via Digitalmars-d wrote:
> void f() pure nothrow @nogc
> {
>    void localFunc()
>    {
>    }
>
>    localFunc();
> }
>
> Complains because localFunc is not @nogc or nothrow.
> Doesn't complain about pure though.
>
> Is it reasonable to say that the scope of the outer function is
> nothrow+@nogc, and therefore everything declared within should also be
> so?

No as the function could be returned and used elsewhere, where these attribute aren't necessary. Also, inferring everything is quite expensive and we want D to compile fast.

But maybe inference could be triggered on error ?
September 28, 2014
On 9/27/2014 7:56 PM, deadalnix wrote:
> On Sunday, 28 September 2014 at 02:42:29 UTC, Manu via Digitalmars-d wrote:
>> void f() pure nothrow @nogc
>> {
>>    void localFunc()
>>    {
>>    }
>>
>>    localFunc();
>> }
>>
>> Complains because localFunc is not @nogc or nothrow.
>> Doesn't complain about pure though.
>>
>> Is it reasonable to say that the scope of the outer function is
>> nothrow+@nogc, and therefore everything declared within should also be
>> so?
>
> No as the function could be returned and used elsewhere, where these attribute
> aren't necessary. Also, inferring everything is quite expensive and we want D to
> compile fast.
>
> But maybe inference could be triggered on error ?

Since the function body is always present, inference should always be done. It isn't costly. Should file an enhancement request on this.
September 28, 2014
On Sunday, 28 September 2014 at 03:08:09 UTC, Walter Bright wrote:
> Since the function body is always present, inference should always be done. It isn't costly. Should file an enhancement request on this.

If you have a control flow graph to analyze it can become quite costly.
September 28, 2014
On 9/27/2014 8:50 PM, deadalnix wrote:
> On Sunday, 28 September 2014 at 03:08:09 UTC, Walter Bright wrote:
>> Since the function body is always present, inference should always be done. It
>> isn't costly. Should file an enhancement request on this.
>
> If you have a control flow graph to analyze it can become quite costly.

Nope! It happens as part of semantic analysis.
September 28, 2014
On Sunday, 28 September 2014 at 04:04:24 UTC, Walter Bright wrote:
> On 9/27/2014 8:50 PM, deadalnix wrote:
>> On Sunday, 28 September 2014 at 03:08:09 UTC, Walter Bright wrote:
>>> Since the function body is always present, inference should always be done. It
>>> isn't costly. Should file an enhancement request on this.
>>
>> If you have a control flow graph to analyze it can become quite costly.
>
> Nope! It happens as part of semantic analysis.

Obviously, it does. The complexity of the computation still can go quite high.
September 28, 2014
On 9/27/2014 10:48 PM, deadalnix wrote:
> On Sunday, 28 September 2014 at 04:04:24 UTC, Walter Bright wrote:
>> On 9/27/2014 8:50 PM, deadalnix wrote:
>>> On Sunday, 28 September 2014 at 03:08:09 UTC, Walter Bright wrote:
>>>> Since the function body is always present, inference should always be done. It
>>>> isn't costly. Should file an enhancement request on this.
>>>
>>> If you have a control flow graph to analyze it can become quite costly.
>>
>> Nope! It happens as part of semantic analysis.
>
> Obviously, it does. The complexity of the computation still can go quite high.

If you look at how it is currently implemented, you'll see it doesn't go high.
September 28, 2014
deadalnix:

> the function could be returned and used elsewhere, where these attribute aren't necessary.

Filed:
https://issues.dlang.org/show_bug.cgi?id=13550

Bye,
bearophile
September 28, 2014
On 9/28/2014 1:49 AM, bearophile wrote:
> Filed:
> https://issues.dlang.org/show_bug.cgi?id=13550

Thanks!
September 28, 2014
On 9/27/14, 7:42 PM, Manu via Digitalmars-d wrote:
> void f() pure nothrow @nogc
> {
>     void localFunc()
>     {
>     }
>
>     localFunc();
> }
>
> Complains because localFunc is not @nogc or nothrow.
> Doesn't complain about pure though.
>
> Is it reasonable to say that the scope of the outer function is
> nothrow+@nogc, and therefore everything declared within should also be
> so?

Interesting. I'd guess probably not, e.g. a function may define a static local function and return its address (without either throwing or creating garbage), whereas that local function itself may do whatever it pleases.

However, local functions have their body available by definition so they should have all deducible attributes deducted. That should take care of the problem.


Andrei

P.S. I also notice that my latest attempt at establishing communication has remained ignored.

« First   ‹ Prev
1 2 3 4 5