Greenwashing

Steven Schveighoffer schveiguy at gmail.com
Thu May 28 15:28:02 UTC 2020


On 5/28/20 11:16 AM, Paolo Invernizzi wrote:
> On Thursday, 28 May 2020 at 15:00:11 UTC, Steven Schveighoffer wrote:
>> On 5/28/20 3:36 AM, Paolo Invernizzi wrote:
>>> What make me feel "mhmm" is that the motivation is always "because no 
>>> throw is speediest, so should be the default" ...
>>
>> That's not the motivation for the default.
> 
> DIP 1029, Rationale:
> 
> "The problem is that exceptions are not cost-free, even in code that 
> never throws. Exceptions should therefore be opt-in, not opt-out. 
> Although this DIP does not propose making exceptions opt-in, the throw 
> attribute is a key requirement for it. The attribute also serves well as 
> documentation that yes, a function indeed can throw."
> 
> Maybe I'm wrong, but when Walter uses "not cost-free" he seldom refers 
> to something else than ... speed.

I should be clearer that MY motivation for having these things be the 
default is so that more code can be used in more situations. Walter's 
motivation may differ.

The fact that this function is not @nogc @safe pure nothrow is a failure 
of the language:

int multiply(int x, int y) { return x * y; }

I shouldn't have to have attribute soup everywhere, and most likely I'm 
not going to bother.

The motivation for the existence of nothrow in general is to avoid the 
cost of exception handling.

But the motivation of making it the *default* is because people just 
don't mark their nothrow functions nothrow. The easier default is 
nothrow because it is callable from either situation.

In other words, it enables more code.

-Steve


More information about the Digitalmars-d mailing list