June 26, 2011 [dmd-internals] Changes for pure, nothrow, and @safe done for the moment? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu |
On 6/26/2011 9:20 PM, Andrei Alexandrescu wrote:
> On 6/26/11 11:00 PM, Walter Bright wrote:
>> On 6/26/2011 8:50 PM, Andrei Alexandrescu wrote:
>>> On 6/26/11 10:34 PM, Walter Bright wrote:
>>>> I'm going to just back out the warning about pure functions with no effect.
>>>
>>> Why? I think that would be a mistake. Roll in any way you wish (after fixing bugs and all), but do roll it it. There's absolutely never a good reason to call a pure function and ignore its result, unless you just want to keep the CPU warm.
>>>
>>
>> Because with pure & nothrow inference, it breaks a lot of code, for example code like this:
>>
>> void foo(int i)
>> {
>> assert(i == 3);
>> }
>
> Hmmm... in this case, the function may terminate the program. Probably in such a case there should be no warning anyway - it does have an effect.
>
Yeah, well, we have no attribute for that.
|
June 26, 2011 [dmd-internals] Changes for pure, nothrow, and @safe done for the moment? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis |
On 6/26/2011 9:29 PM, Jonathan M Davis wrote:
> Certainly, the situation with this is far more complicated than it first appears.
>
>
Yup. Hence it was dumped for the time being.
|
June 27, 2011 [dmd-internals] Changes for pure, nothrow, and @safe done for the moment? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 6/27/11 5:50 AM, Andrei Alexandrescu wrote: > [?] There's absolutely never a good > reason to call a pure function and ignore its result, unless you just > want to keep the CPU warm. There is, especially with pure/nothrow inference for delegates ? a prominent example is std.concurrency.receive, which I brought up in the commit comments yesterday: https://github.com/D-Programming-Language/dmd/commit/9b50184c#commitcomment-448720. David |
June 27, 2011 [dmd-internals] Changes for pure, nothrow, and @safe done for the moment? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On 6/27/11 2:38 AM, David Nadlinger wrote:
> On 6/27/11 5:50 AM, Andrei Alexandrescu wrote:
>> [?] There's absolutely never a good
>> reason to call a pure function and ignore its result, unless you just
>> want to keep the CPU warm.
>
> There is, especially with pure/nothrow inference for delegates ? a
> prominent example is std.concurrency.receive, which I brought up in the
> commit comments yesterday:
> https://github.com/D-Programming-Language/dmd/commit/9b50184c#commitcomment-448720.
That would enter under the empty body case.
Andrei
|
Copyright © 1999-2021 by the D Language Foundation