My Long Term Vision for the D programming language

tsbockman thomas.bockman at gmail.com
Sat Nov 20 05:13:01 UTC 2021


On Saturday, 20 November 2021 at 03:38:01 UTC, rikki cattermole 
wrote:
> And truth be told I think we *do* need to build that IR at some 
> point, because right now with the return ref and all those 
> attributes its just garbage that humans have to write that 
> rather than letting the compiler figure it out.

The compiler already does figure most of it out. That's how it 
can emit compile time error messages for missing or incorrect 
attributes, or implementation violations of an attribute's 
guarantees. The attributes exist primarily for two reasons:

1) To verify programmer intent, that the inferred attributes of 
the code written match the intended attributes.

2) To specify APIs independent of implementation, for `extern` 
linking, `interface`s and base `class`es with multiple 
implementations that might imply different attributes, etc.

Attribute soup is unavoidable for (2) public APIs in general; 
there is nowhere else the information *can* come from in many 
cases except from an explicit specification, regardless of how 
sophisticated the compiler is.

Redundant specification of attributes for (1) verification 
purposes could be dropped, but I'd rather not since I find the 
compiler frequently catches mistakes or fuzzy thinking on my part 
by comparing explicit attributes to inferred.


More information about the Digitalmars-d mailing list