Justin
Fri Jul 16 12:55:49 CDT 2004
Alec wrote:
> Basically I'm looking for the :: C++ operator equivalent. I ended up
> renaming the function to get around it, but I'd like to know if it's
> possible for the future.
The specific example of overriding built-in functions sounds like a
maintenance nightmare, but I can imagine the usefulness of calling a
global function from a class where a member function having the same
name exists.
The ExecuteGlobal statement has exactly the effect desired, however it
is severely limited by the inability to pass anything that can't easily
be represented as a string without resorting to global variables. With
that avenue closed, I think that only leaves supplying an additional
name for the global function.
In the example below, a Load() function exists in both the global
namespace and in the GlobalTest class. A disambiguation function has
been added to the global namespace, which simply returns the value from
the global Load(). I have used "::" as the prefix for the disambiguation
function, partly because it makes it obvious that something out of the
ordinary is happening, but mostly because it is unlikely that any
similarly-named functions exist. "G_" or "Global_" or anything else you
like could easily be used in its stead.
Class GlobalTest
Public Function Load()
Load = "GlobalTest::Load"
End Function
Public Function Test()
WScript.Echo Load()
WScript.Echo [::Load]()
End Function
End Class
Function Load()
Load = "::Load"
End Function
Function [::Load]()
[::Load] = Load()
End Function
Dim gt : Set gt = New GlobalTest
gt.Test
--
Justin Piper
Bizco Technologies
http://www.bizco.com/