4 ms·
This is exciting! A few years ago, someone created dotc [0], which lets you use node-style require and export in C. With that said, from skimming the document
by TheAceOfHearts 11y ago
This is exciting!
A few years ago, someone created dotc [0], which lets you use node-style require and export in C.
With that said, from skimming the document, I'm not a big fan of this variation of imports. You're dumping everything from the library into your environment. IMO, this makes it really difficult to trace code and figure out where stuff comes from.
For comparison, with ES6 you specify what you're importing and from where you're importing it:
import * as Foo from './Foo'
import { bar, baz } from './Bar'
When I see baz() used in my code, I know that I can look in the Bar file for its definition.
Isn't this a concern? I must recognize, though, that I've barely touched C++, so maybe I just don't know any better.
[0] https://github.com/substack/dotc https://github.com/substack/dotc
- lunula 11y agoThis is written by substack, who is among the most prolific (if not the most prolific) contributors to npm. Node.js has benefitted from the power of standard packaging. It is really incredible how easy it is to work in that ecosystem. Provided a solid mechanism for packaging and dependency description the same pattern should be possible in C++ as well. I look forward to that day. Things will really take off when it costs almost nothing to leverage someone else's work in a controlled way.
- yoklov 11y agoPartially importing symbols from a header file in C++ could easily lead to bugs due to the way that name resolution and ADL work. I think doing this in a satisfactory way would end up being extremely complicated, and adding even more complexity to how C++ name resolution works is... undesirable. But moreover, for this to be maximally useful, it needs to work with the large set of existing C and C++ libraries.