compilation - What's NOT in an interface file? -


i under impression "a d interface file contains import of module needs, rather whole implementation of module." me, translates signatures - return types, names , arguments, compiler knows it's valid , linker can dirty work later.

running file through dmd, though, strips nothing:

import std.stdio;  void sayhello(const string name) {     writeln("hello, ", name, "!"); } 

dmd interface.d -o- -h 

// d import file generated 'interface.d' import std.stdio; void sayhello(const string name) { writeln("hello, ",name,"!"); } 

hardly paragon of optimization.

what, exactly, stripped in interface files?

( added because it's closest thing find.)

any function going inlined must have full source in .di file. function going used in ctfe must not have full source in .di file, full source of every function uses - directly or indirectly - must available compiler. also, because of how templates work, full source must in .di file (which same how templates must in header files in c++). so, there number of cases need stuff in .di file.

under circumstances compiler chooses strip stuff or not, don't know (aside fact templates automatically end in .di files in entirety because have to). change depending on compiler's current implementation , optimizations does. @ minimum, it's going have leave in small function bodies if it's going inlining. large function bodies , bodies of small virtual functions (which can't inlined anyway) stripped out however. example gives small, non-virtual function, dmd left in inline calls it. if want see dmd strip lot of stuff when generating .di file, need have large functions and/or use classes.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -