[Does Nim need package-level visibility? - Nim
forum]([https://forum.nim-lang.org/t/4293](https://forum.nim-lang.org/t/4293))
suggested introducing package-level visibility and gave proper rationale for
why something like that; however, as noted, it would add complexity to the
language (eg: no syntax for that was suggested and it's not clear how to extend
the simple * for package-level visibility; likely a macro {.pkg.} would be
needed.
Instead, I'd like to suggest something simpler:import foo {.private.} (syntax
can be discussed) which imports symbols in foo, as if they were declared
public, eg:
foo.nim:
type Bar* = object
field1*: int
field2: float
proc bar(a:int): int = ...
Run
tfoo.nim:
import foo {.private.}
doAssert bar(10) == 10 # we can access `bar` thanks to `{.private.}` pragma
Run
The idea is to provide an escape hatch to visibility, and the user of
{.private.} knows what he's doing. In particular, changes to private symbols
are still allowed and are **not considered breaking changes**.
Since typically {.private.} would be used within boundaries of a library, this
wouldn't result in actual breakages.
Additional use cases are enabled by this feature, notably for debugging
purposes.