Hi all! I'm trying to remove some prefixes from the names of procedures in my GBA library.
Currently a "hello world" program looks like this: import natu irqInit() irqEnable(II_VBLANK) tteInitChr4cDefault(bgnr = 0, initBgCnt(cbb = 0, sbb = 31)) tteWrite("Hello world") while true: VBlankIntrWait() Run I want it to look like this: import natu irq.init() irq.enable(II_VBLANK) tte.init(bgnr = 0, initBgCnt(cbb = 0, sbb = 31)) tte.write("Hello world") while true: VBlankIntrWait() Run i.e. simplify all the names and use the module name to disambiguate. The library is already split into several modules, which are forwarded from natu.nim via `export`: import natu/private/[ types, memmap, memdef, bios, core, input, irq, math, oam, surface, tte, video, reg ] export types, memmap, memdef, bios, core, input, irq, math, oam, surface, tte, video, reg Run Unfortunately my desired hello world seems impossible with this approach, because `export somemodule` does not make the symbol `somemodule` usable in the importing file. Here's a minimal example: I _want_ to do `b.foo()` but I'm forced to do `a.foo()` **a.nim** import b export b Run **b.nim** proc foo*() = echo "hello" Run **main.nim** import a a.foo() # works, but not what I want # b.foo() # doesn't work :( Run * * * **Workarounds** Here are some solutions I've considered: 1\. Require **separate imports** import natu/[core, input, video, math, irq, tte, bios] Run This sucks because it introduces needless extra overhead for developers. You have to deal with unused import warnings (or disable them), you have to learn where everything comes from and constantly scroll up to edit the top of the file. 2\. Introduce just **a few extra imports** import natu/[common, irq, tte] Run Most modules don't really have the prefixing issue, `irq` and `tte` are the troublemakers, so I could just split those out and keep everything else in the core module. This _kinda_ solves it, but the division feels pretty arbitrary - these modules aren't any more or less important than input, math, video etc. Also the problems of the previous point still apply somewhat. 3\. **" Include"-able prelude** include natu/common # equivalent to: # {.warning[UnusedImport]: off.} # import natu/[core, input, video, math, irq, tte, bios] Run Works but I'd rather not force `include` upon my users... 4\. Some hacks using **dummy objects to enforce dot notation** import natu/private/tte as m_tte const tte* = TTEModule() proc init*(module: static[TTEModule]) = m_tte.init() Run This seems like over-engineering. It clutters jump-to-definition, `nim doc`, etc. The old prefixed functions were better than this. * * * In summary, I want `export mymodule` to make the symbol `mymodule` available to the importing code. Is this something that the language could support in the future? Is there a recommended workaround? Thanks!