The following Code
class MySuperClass
constructor
self:_setup()
hidden method _setup()
Safedebout32("mysuperclass",classname(self))
return
end class
class MySubClass inherit MySuperClass
hidden method _setup()
Safedebout32("mysubclass",classname(self))
return
end class
function TestCode() as usual clipper
local o as MySubClass
o := MySubClass{}
return
arrives at the green Line in VO and at the red line in X#. Do we really need to refactor all these occurences or is there some switch to enable VO-like behaviour in this case?
P.S.: If I omit the HIDDEN statement the behaviour is the same in both languages.
Overwriting hidden methods: X# vs VO
-
- Posts: 71
- Joined: Thu Jul 15, 2021 10:46 am
- Location: Germany
Overwriting hidden methods: X# vs VO
Hi Stefan,
I think that's a bug in VO. By definition a HIDDEN (or PRIVATE as is usually called in .Net) method is only visible in the same class that it is declared in and completely invisible from anywhere else, including subclasses, so it cannot be called from the child constructor. Why had you defined the methods as HIDDEN, maybe you intended to define them as PROTECTED?
(not blaming you, I know that due to its very sloppy compiler VO allowed a lot of things to compile and work at runtime in a way that they never should had. X# revealed a lot of similar issues in my VO code, and everybody else's basically)
I think that's a bug in VO. By definition a HIDDEN (or PRIVATE as is usually called in .Net) method is only visible in the same class that it is declared in and completely invisible from anywhere else, including subclasses, so it cannot be called from the child constructor. Why had you defined the methods as HIDDEN, maybe you intended to define them as PROTECTED?
(not blaming you, I know that due to its very sloppy compiler VO allowed a lot of things to compile and work at runtime in a way that they never should had. X# revealed a lot of similar issues in my VO code, and everybody else's basically)
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Overwriting hidden methods: X# vs VO
Stefan,
In VO all methods are virtual. Apparently this means that you can override a hidden method.
In .Net private methods are never virtual (because they cannot be overwritten in subclasses).
Robert
In VO all methods are virtual. Apparently this means that you can override a hidden method.
In .Net private methods are never virtual (because they cannot be overwritten in subclasses).
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
-
- Posts: 71
- Joined: Thu Jul 15, 2021 10:46 am
- Location: Germany
Overwriting hidden methods: X# vs VO
Thanks for clarifying. Unfortunately this special construct is Part of one of our most used design patterns which means that we should probably remote all our "hidden" Statements in Vo before continuing the migration...
Overwriting hidden methods: X# vs VO
Instead of removing the Hidden Modifier, you could consider replacing it with the Proteced modifier.
Protected methods can be overridden but are only visible to class and all inherited classes but as hidden methods, they can not be called from other classes.
Volkmar
Protected methods can be overridden but are only visible to class and all inherited classes but as hidden methods, they can not be called from other classes.
Volkmar