I have this problem for homework:
For module1, module2, and the client module shown below, indicate which of the imported identifiers would result in a name clash if the imported identifiers were not fully qualified.
I answered:
func_2
clashes between module2
and module3
func_3
clashes between module2
and main
However, the answer listed in the text is just
func_3
.
Am I wrong?
Thank you.
In module1, there is no name clash, because module1 does not know that module2 and client module exist. module2 does not know that module1 and client module exist. client module, however, imports module1 and module2. Therefore, it has defined func_1 once (in module1), func_2 twice (in module1 and module2), and func_3 twice (in module2 and client module). For illustration, I'll write two files: main_module and imported_module.
imported_module looks like this:
main_module looks like this:
The result of running main_module:
main_module has both variables, because it defined y and imported x. imported_module has x, because it defined it, but it does not have y.