Change the way UseModule checks for ambiguity
Posted: Sun Jun 30, 2013 8:34 pm
As a remainder in the appropriate section + example.
http://www.purebasic.fr/english/viewtop ... 57#p415657
Example:
In the example above, it's impossible to use UseModule because the compiler would raise an error on the line "UseModule test" since it finds another "hello()" clashing with the "hello()" inside the module.
Making the compiler to raise the error only if we try to invoke in an ambiguous way the "hello()" procedure (and not before just assuming we could do it) we have more freedom:
Thanks
http://www.purebasic.fr/english/viewtop ... 57#p415657
fred wrote:for now it raises an error if one function collide. But we could change that to raise the error when the ambiguous function is called, so you have to choose the right one for this case.
Example:
Code: Select all
Procedure hello()
Debug "external hello"
EndProcedure
DeclareModule test
Declare one()
Declare two()
Declare hello()
EndDeclareModule
Module test
Procedure one()
Debug "one"
EndProcedure
Procedure two()
Debug "two"
EndProcedure
Procedure hello()
Debug "module's hello"
EndProcedure
EndModule
hello()
; the line below would cause the compiler to raise an error
; UseModule test
; we can solve the problem only this way for now
test::one()
test::two()
test::hello()
Making the compiler to raise the error only if we try to invoke in an ambiguous way the "hello()" procedure (and not before just assuming we could do it) we have more freedom:
Code: Select all
Procedure hello()
Debug "external hello"
EndProcedure
DeclareModule test
Declare one()
Declare two()
Declare hello()
EndDeclareModule
Module test
Procedure one()
Debug "one"
EndProcedure
Procedure two()
Debug "two"
EndProcedure
Procedure hello()
Debug "module's hello"
EndProcedure
EndModule
hello()
UseModule test ; compiler keeps silent for now, maybe we will not call the module's "hello()" ... it waits
one() ; no problem
two() ; no problem
; the "hello()" below would cause the compiler to raise an error
; hello()
test::hello() ; we resolve the conflict using "::" and we don't lose the ability to use "UseModule" just for a single problematic procedure