auto attribution pros/cons

Bruce Carneal bcarneal at gmail.com
Sun Jun 28 22:56:55 UTC 2020


On Sunday, 28 June 2020 at 22:29:01 UTC, Ben Jones wrote:
> On Sunday, 28 June 2020 at 18:39:13 UTC, Bruce Carneal wrote:
>> Corrections to the above?  Better terminology?  Other 
>> pros/cons?
>>
>> Note: the auto attribution idea is not original, I've just not 
>> seen it reviewed.
>
>
> What about adding "auto" an attribute that means "infer 
> attributes?"

Template functions with zero template arguments, ala
  int tfunc()(int x) { return x; },
are pretty close to that idea already.

A difference between auto attribution and "template auto" is that 
the latter adapts to its surroundings while the former would go 
hard over to different defaults when the attributes in question 
are machine provable e.g: @safe pure nothrow.

As proposed auto attribution would bias towards safety but would, 
as kinke notes, cause some programs to run slower until explicit 
performance attribution was put in place.  Not a "breaking" 
change exactly but a "performance breaking" change.







More information about the Digitalmars-d mailing list