How to prevent definitions leaks from imports? (namespace is currently global)
mationai opened this issue · 1 comments
defined a function called sum
.
Compiler errors on "Duplicate name 'sum'" if I import fs/filesystem
;
No error if not importing fs/filesystem
;
2 issues here.
-
How to avoid importing everything in
fs/filesystem
when I want to import only selected ones? -
Worst, seems like
sum
was leaked fromfs/filesystem
due to it importing:
math/md5 -> math/bits -> math/math wheresum
was defined.
Flow has a global namespace at the moment, so there is no way to avoid that. From the FAQ:
Why is there a global name space?
Yeah, this sucks, but it is hard to fix. It requires changing not only the compiler and all
the backends, but also the debugger, the profiler and other similar tools. We originally
thought that we would have to fix this quickly to be able to work many people together, but
after many years of working with flow, it turns out not to be as bad. Of course, it is annoying,
and we want to fix it, but at the same time, in practice, there are also what we can call
collateral benefits. The most important is that any top-level name is unambiguous which helps
communication and avoid mistakes.
However, it might be something we will try to tackle.