Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent definitions leaks from imports? (namespace is currently global) #218

Open
mationai opened this issue May 3, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@mationai
Copy link
Contributor

mationai commented May 3, 2019

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.

  1. How to avoid importing everything in fs/filesystem when I want to import only selected ones?

  2. Worst, seems like sum was leaked from fs/filesystem due to it importing:
    math/md5 -> math/bits -> math/math where sum was defined.

@alstrup
Copy link
Contributor

alstrup commented May 4, 2019

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.

@alstrup alstrup changed the title How to prevent definitions leaks from imports? How to prevent definitions leaks from imports? (namespace is currently global) May 6, 2019
@alstrup alstrup added the enhancement New feature or request label May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants