SE-0491: Module selectors for name disambiguation

I expect some people will use :: defensively within the package ecosystem to improve source compatibility. I think usage could become more widespread than what seems to be expected here.

Currently if you import library A and library B, you may get surprises if a newer version of library B introduces a symbol with the same name as one that is already present in library A. If you’re vending a package C that makes use of A and B, an update to either A or B with new symbols could break compilation of package C and impact every client of C.

If you gain the ability to prefix everything with A:: and B:: I wouldn’t be surprised if some package authors start to use this extensively. You could even automate it with a linter. This would make package C shielded from new symbols in A and B that could create ambiguities.

For reference, here’s somewhere in the middle of a previous discussion about this:

So this “nest everything” rule could easily transform into “:: everything” for some people who care about semantic versioning.

3 Likes