proposal: lazy compilation model for compiling binaries

Timothee Cour thelastmammoth at gmail.com
Sun Jun 23 18:46:45 PDT 2013


On Sun, Jun 23, 2013 at 5:36 PM, Martin Nowak <code at dawg.eu> wrote:

> On 06/22/2013 06:45 AM, Timothee Cour wrote:
>
>> Example2:
>> ----
>> auto foo(){return "import std.stdio;";}
>> mixin(foo);
>> void fun2(){import b;}
>> void main(){writeln("ok");}
>> ----
>> lazy semantic analysis will analyze main, foo but not fun2, which is not
>> used. foo is analyzed because it is used in a module-level mixin
>> declaration.
>>
>>  Overall it's a good idea. There are already some attempts to shift to
> lazy semantic analysis, mainly to solve any remaining forward reference
> issues.
> Also for non-optimized builds parsing takes a huge part of the compilation
> time so that would remain, I don't have detailed numbers though.
>

why 'that would remain' ? in the proposed lazy compilation model,
optimization level is irrelevant. The only thing that matters is whether we
have to export all symbols or only specified ones. I agree we should
require marking those explicitly with 'export' on all platforms, not just
windows. But in doing so we must allow to define those exported symbols
outside of where they're defined, otherwise it will make code ugly (eg,
what if we want to export std.process.kill in a user shared library and
std.process.kill isn't marked as export)

Here's a possibility

module define_exported_symbols;
import std.process;
export std.process.kill; //export all std.process.kill overloads (just 1
function in this case)
export std.process; //export all functions in std.process
export std; //export all functions in std

But I think the best is to keep the current export semantics (but make it
work on all platforms not just windows) and provide library code to help
with exporting entire modules/packages:

module std.sharedlib; //helper functions for dlls on all platforms
void export_module(alias module_)(module_ mymodule){
}
void export_symbols(R) (R symbols) if(isInputRange!R){//export a range of
symbols
}
/+
usage:
export_module(std.process); //exports all functions in std.process
export_symbols(enumerateFunctions(std.process)); //exports all functions in
std.process; allows to be more flexible by exporting only a subset of those
+/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130623/a199bb96/attachment-0001.html>


More information about the Digitalmars-d mailing list