On Friday, 5 December 2014 at 02:38:48 UTC, Daniel Murphy wrote:
"H. S. Teoh via Digitalmars-d" wrote in message news:[email protected]...

I've often pondered about the possibility of a language where the compiler will analyze each module and infer any number of attributes and optimization opportunities for each symbol exported by that module, and this information will be saved in the object file (or some other kind of interfacing file). This includes any half-compiled template bodies and whatever else that can't be fully codegen'd until actual use. The attributes will include all sorts of stuff that programmers normally wouldn't want to deal with -- there could be 10+ or 50+ attributes representing various optimization / static checking opportunities. Then every time a module is imported by another module, the compiler never goes to the source code of the imported module anymore, but it will read the object (interface) file, which is fully attributed, and the saved attributes will be used internally for static checking, optimization,
and inferring attributes for the current module.

This can't be used to infer attributes that can produce errors - those attributes have to be user-visible or the errors don't make any sense. If it's purely for optimization, then that's basically what LTO does.

We could inter attributes if not specified instead of assuming a
default, for example @nogc and a possible @gc.

---

int[] foo1(int[] bar) @nogc // function is @nogc, error if gc is
used
int[] foo2(int[] bar) @gc // function is @gc, functions that call
foo2 cannot be @nogc
int[] foo3(int[] bar) // neither @nogc nor @gc, compiler infers
attribute
---

Reply via email to