4 ms·
4.) In the source file where the two are composed. In general, modules should not import their dependencies, but have them provided to them by their common pa
by mpweiher 9y ago
4.) In the source file where the two are composed.
In general, modules should not import their dependencies, but have them provided to them by their common parent. See Newspeak's module system as an example.
- cousin_it 9y agoRadical! But doesn't that mean the first module can't be typechecked in isolation? I see Newspeak is dynamically typed so maybe it's not a problem there, but what's the right solution for statically typed languages then?
- qznc 9y agoSpecify an interface. Alternatively, infer the interface and type check that in the composing module.
- mpweiher 9y agoNewspeak is intended to be statically typed, presumably optionally/gradually. I think the implementation is missing right now, though the syntax already allows type annotations. As the other commenter wrote, the answer is that modules can never "import" concrete modules, only interfaces. And that means some extra effort, though having type-inference assist with the construction of that module should help. Definitely something that needs figuring out. IMHO, explicit composition is something we really need to figure out in general, and it should solve the weird mix of linguistic and extra-linguistic mechanisms we have now.