Suppose you write a lib in source form using modules, and when the user of your lib includes it in his main project there is some name clashing.
Example of a worst case scenario:
Code: Select all
Procedure func()
Debug "main"
EndProcedure
DeclareModule lib1
#test_const = 111
Declare func(par)
EndDeclareModule
Module lib1
Procedure func(par)
Debug "lib1 func:" + par
EndProcedure
EndModule
DeclareModule lib2
#test_const = 222
Declare func(par)
EndDeclareModule
Module lib2
Procedure func(par)
Debug "lib2 func:" + par
EndProcedure
EndModule
lib1::func(lib1::#test_const)
lib2::func(lib2::#test_const)
func()
It seem (if I'm not missing something) right now the only option (apart changing some of the sources OBVIOUSLY please don't suggest that) is to use the fully qualified name for everything, as I did above.
This can be ok if you have not much to call, but imagine if it's not the case.
Couldn't be partially solved accepting this code (currently not compilable because raises an error) ?
Code: Select all
Procedure func()
Debug "main"
EndProcedure
DeclareModule lib1
#test_const = 111
Declare func(par)
EndDeclareModule
Module lib1
Procedure func(par)
Debug "lib1 func:" + par
EndProcedure
EndModule
DeclareModule lib2
#test_const = 222
Declare func(par)
EndDeclareModule
Module lib2
Procedure func(par)
Debug "lib2 func:" + par
EndProcedure
EndModule
; all the above is identical
UseModule lib1 ; don't raise an error anymore here
func(#test_const) ; and here call the func in the only matching module instead
UseModule lib2 ; now the matching modules would be two... potential problem
lib2::func(lib2::#test_const) ; but not if I fully qualify it (or close the previous module before, I can choose)
::func() ; I want to call the global func(), so I just prepend "::" to it
Just thinking out loud, and considering probably it's still a GOOD idea to use prefix like lib1_func() etc, even when using modules.
Comments about all this ?
EDIT: corrected a typo