4 ms·
Modules were added to C with 10 lines of code: https://nwcpp.org/April-2022.html https://nwcpp.org/April-2022.html https://dlang.org/spec/importc.html#__impor
by WalterBright 5y ago
Modules were added to C with 10 lines of code:
https://nwcpp.org/April-2022.html https://nwcpp.org/April-2022.html
https://dlang.org/spec/importc.html#__import https://dlang.org/spec/importc.html#__import
The same technique could be used with C++.
- WalterBright 5y agoThe method is based on the idea that the product of the semantic pass of a compiler is a symbol table. Then, to make imports work: 1. add some syntax to import a module 2. create another instance of the compiler to compile that module and return the symbol table 3. have the importer, when it doesn't find a symbol in the symbol table, to search the symbol tables of the imports