[OT] Clang seems to implement modules

Jacob Carlborg doob at me.com
Mon Nov 19 12:18:51 PST 2012


On 2012-11-19 10:58, Paulo Pinto wrote:

> I don't see what it would break, besides the pre-processor usage.

Exactly:

"‘import’ ignores preprocessor state within the source file".

But what I don't understand is that on a few slides later it says:

"What Does import Import?"

And:

"Functions, variables, types, templates, macros, etc."

Note it says "macros".

> Modules mean that the compilers just need to read a symbol table
> or an AST from an external file.

That's basically how it works:

1. Find a module map for the named module
2. Spawn a separate instance of the compiler:
  2a. Parse the headers in the module map
  2b. Write the module file
3. Load the module file at the ‘import’ declaration
4. Cache module file for later re-use

I think this is only to be compatible with pre-existing headers.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list