Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Overwriting hidden methods: X# vs VO 10 Mar 2023 13:21 #25588

  • stefan.ungemach
  • stefan.ungemach's Avatar
  • Topic Author


  • Posts: 14
  • 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.

    Please Log in or Create an account to join the conversation.

    Last edit: by stefan.ungemach.

    Overwriting hidden methods: X# vs VO 10 Mar 2023 16:47 #25593

    • Chris
    • Chris's Avatar


  • Posts: 3981
  • 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)
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Overwriting hidden methods: X# vs VO 11 Mar 2023 07:57 #25601

    • robert
    • robert's Avatar


  • Posts: 3599
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Overwriting hidden methods: X# vs VO 11 Mar 2023 08:12 #25603

    • stefan.ungemach
    • stefan.ungemach's Avatar
    • Topic Author


  • Posts: 14
  • 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...

    Please Log in or Create an account to join the conversation.

    Overwriting hidden methods: X# vs VO 11 Mar 2023 08:49 #25605

    • VR
    • VR's Avatar


  • Posts: 87
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1