Explicit Virtual Functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sarath

    #1

    Explicit Virtual Functions

    Hi All,

    Could you please give some good links to learn about the "Proposed new
    syntax for Virtual functions" in the new standard?

    If you could explain it in simple manner as a reply that will be very
    helpful. I just referred Wikipedia for the same. But still looking for
    a simple description for same.

    Regards,
    Sarath

  • John Harrison

    #2
    Re: Explicit Virtual Functions

    Sarath wrote:
    Hi All,
    >
    Could you please give some good links to learn about the "Proposed new
    syntax for Virtual functions" in the new standard?
    >
    If you could explain it in simple manner as a reply that will be very
    helpful. I just referred Wikipedia for the same. But still looking for
    a simple description for same.
    >
    Regards,
    Sarath
    >
    This is official



    and seems easy enough. It's just a machanism for avoiding mistakes when
    writing a derived class.

    Can't say I like it very much at first glance.

    john

    Comment

    • Sarath

      #3
      Re: Explicit Virtual Functions

      On Mar 4, 6:49 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
      Sarath wrote:
      Hi All,
      >
      Could you please give some good links to learn about the "Proposed new
      syntax for Virtual functions" in the new standard?
      >
      If you could explain it in simple manner as a reply that will be very
      helpful. I just referred Wikipedia for the same. But still looking for
      a simple description for same.
      >
      Regards,
      Sarath
      >
      This is official
      >

      >
      and seems easy enough. It's just a machanism for avoiding mistakes when
      writing a derived class.
      >
      Can't say I like it very much at first glance.
      >
      john

      I'm really confused with one of the explanation I found in Wikipedia


      I think these are ablsolutely different one.

      Comment

      • John Harrison

        #4
        Re: Explicit Virtual Functions

        Sarath wrote:
        On Mar 4, 6:49 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
        >
        >>Sarath wrote:
        >>
        >>>Hi All,
        >>
        >>>Could you please give some good links to learn about the "Proposed new
        >>>syntax for Virtual functions" in the new standard?
        >>
        >>>If you could explain it in simple manner as a reply that will be very
        >>>helpful. I just referred Wikipedia for the same. But still looking for
        >>>a simple description for same.
        >>
        >>>Regards,
        >>>Sarath
        >>
        >>This is official
        >>
        >>http://www.open-std.org/jtc1/sc22/wg...006/n2108.html
        >>
        >>and seems easy enough. It's just a machanism for avoiding mistakes when
        >>writing a derived class.
        >>
        >>Can't say I like it very much at first glance.
        >>
        >>john
        >
        >
        >
        I'm really confused with one of the explanation I found in Wikipedia

        >
        I think these are ablsolutely different one.
        >
        Yep, they seem to be tackling the same issue but in very different ways.

        Comment

        • Pete Becker

          #5
          Re: Explicit Virtual Functions

          Sarath wrote:
          >
          I'm really confused with one of the explanation I found in Wikipedia

          >
          That's not surprising: the explanation is quite muddled.

          --

          -- Pete
          Roundhouse Consulting, Ltd. (www.versatilecoding.com)
          Author of "The Standard C++ Library Extensions: a Tutorial and
          Reference." (www.petebecker.com/tr1book)

          Comment

          • Sarath

            #6
            Re: Explicit Virtual Functions

            On Mar 5, 12:45 am, Pete Becker <p...@versatile coding.comwrote :
            Sarath wrote:
            >
            I'm really confused with one of the explanation I found in Wikipedia
            http://en.wikipedia.org/wiki/C++0x#E...tual_functions
            >
            That's not surprising: the explanation is quite muddled.
            >
            --
            >
            -- Pete
            Roundhouse Consulting, Ltd. (www.versatilecoding.com)
            Author of "The Standard C++ Library Extensions: a Tutorial and
            Reference." (www.petebecker.com/tr1book)
            yea.. that's a bit difficult to understand. but the original proposal
            (http://www.open-std.org/jtc1/sc22/wg...006/n2108.html -
            posted John harrison ) is lacking of good examples. Anyway I
            understood somewhat from it but when thinking about WIkipedia example
            it makes me confused.

            It seems that the example said in Wikipedia follows the syntax
            proposed early by Bjarne Stroustrup


            Comment

            • bjarne

              #7
              Re: Explicit Virtual Functions

              On Mar 4, 10:45 am, "Sarath" <CSar...@gmail. comwrote:
              >
              It seems that the example said in Wikipedia follows the syntax
              proposed early by BjarneStroustru p
              Not guilty (for a change). That's not one of my proposals.

              Please note that the C++0x design is still in a flux and that you
              can't be certain of details until the votes are done. The wikkipedia
              entry seems a bit "optimistic "/certain in places. For example, there
              is no guarantee that any new facility for controlling overriding will
              be added.


              Comment

              • Sarath

                #8
                Re: Explicit Virtual Functions

                On Mar 5, 7:48 am, "bjarne" <bjarne@gmail.c omwrote:
                On Mar 4, 10:45 am, "Sarath" <CSar...@gmail. comwrote:
                >
                >
                >
                It seems that the example said in Wikipedia follows the syntax
                proposed early by BjarneStroustru p
                >
                Not guilty (for a change). That's not one of my proposals.
                >
                Please note that the C++0x design is still in a flux and that you
                can't be certain of details until the votes are done. The wikkipedia
                entry seems a bit "optimistic "/certain in places. For example, there
                is no guarantee that any new facility for controlling overriding will
                be added.
                Sorry sir,
                It was my assumption when I saw an alternative syntax. In the

                proposal it is also indicating about the alternative syntax specified
                you(Rationale section)... So I thought it other way. Sorry for my
                misinterpretati on.

                Comment

                • Dave Rahardja

                  #9
                  Re: Explicit Virtual Functions

                  On 4 Mar 2007 05:52:40 -0800, "Sarath" <CSarath@gmail. comwrote:
                  >On Mar 4, 6:49 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
                  >Sarath wrote:
                  Hi All,
                  >>
                  Could you please give some good links to learn about the "Proposed new
                  syntax for Virtual functions" in the new standard?
                  >>
                  If you could explain it in simple manner as a reply that will be very
                  helpful. I just referred Wikipedia for the same. But still looking for
                  a simple description for same.
                  >>
                  Regards,
                  Sarath
                  >>
                  >This is official
                  >>
                  >http://www.open-std.org/jtc1/sc22/wg...006/n2108.html
                  >>
                  >and seems easy enough. It's just a machanism for avoiding mistakes when
                  >writing a derived class.
                  >>
                  >Can't say I like it very much at first glance.
                  >>
                  >john
                  >
                  >
                  >I'm really confused with one of the explanation I found in Wikipedia
                  >http://en.wikipedia.org/wiki/C++0x#E...tual_functions
                  >
                  >I think these are ablsolutely different one.
                  Is there really a need for controlling which virtual functions can be
                  specialized? What is the class of problems that this is supposed to solve?

                  I think that a syntax addition that explicitly indicates that a derived class
                  is specializing a base class's virtual function is very useful. The absence of
                  such indications should result in a warning only (to preserve compatibility
                  with old code).

                  I especially like


                  class B
                  {
                  public:
                  virtual void foo() {}
                  };

                  class D: public D
                  {
                  public:
                  virtual void foo(): B {}
                  };


                  It's clean.

                  -dr

                  Comment

                  • Sarath

                    #10
                    Re: Explicit Virtual Functions

                    On Mar 6, 12:17 pm, Dave Rahardja
                    <drahardja_atsi gn_pobox_dot_.. .@pobox.comwrot e:
                    On 4 Mar 2007 05:52:40 -0800, "Sarath" <CSar...@gmail. comwrote:
                    >
                    >
                    >
                    >
                    >
                    On Mar 4, 6:49 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
                    Sarath wrote:
                    Hi All,
                    >
                    Could you please give some good links to learn about the "Proposed new
                    syntax for Virtual functions" in the new standard?
                    >
                    If you could explain it in simple manner as a reply that will be very
                    helpful. I just referred Wikipedia for the same. But still looking for
                    a simple description for same.
                    >
                    Regards,
                    Sarath
                    >
                    This is official
                    >>
                    and seems easy enough. It's just a machanism for avoiding mistakes when
                    writing a derived class.
                    >
                    Can't say I like it very much at first glance.
                    >
                    john
                    >
                    I'm really confused with one of the explanation I found in Wikipedia
                    http://en.wikipedia.org/wiki/C++0x#E...tual_functions
                    >
                    I think these are ablsolutely different one.
                    >
                    Is there really a need for controlling which virtual functions can be
                    specialized? What is the class of problems that this is supposed to solve?
                    >
                    I think that a syntax addition that explicitly indicates that a derived class
                    is specializing a base class's virtual function is very useful. The absence of
                    such indications should result in a warning only (to preserve compatibility
                    with old code).
                    >
                    I especially like
                    >
                    class B
                    {
                    public:
                    virtual void foo() {}
                    >
                    };
                    >
                    class D: public D
                    {
                    public:
                    virtual void foo(): B {}
                    >
                    };
                    >
                    It's clean.
                    >
                    -dr- Hide quoted text -
                    >
                    - Show quoted text -
                    that's a nice proposal :D

                    Comment

                    • frege

                      #11
                      Re: Explicit Virtual Functions

                      On Mar 5, 10:17 pm, Dave Rahardja
                      <drahardja_atsi gn_pobox_dot_.. .@pobox.comwrot e:
                      >
                      I especially like
                      >
                      class B
                      {
                      public:
                      virtual void foo() {}
                      >
                      };
                      >
                      class D: public D
                      {
                      public:
                      virtual void foo(): B {}
                      >
                      };
                      >
                      It's clean.
                      >
                      Microsoft (VC 8) already allows B::foo(). ie:
                      class D: public B
                      {
                      public:
                      virtual void B::foo() {}
                      >
                      };
                      >
                      if B does not have a matching foo, it issues an error.

                      -dr
                      Tony


                      Comment

                      • Sarath

                        #12
                        Re: Explicit Virtual Functions

                        On Mar 6, 1:34 pm, "frege" <gottlobfr...@g mail.comwrote:
                        On Mar 5, 10:17 pm, Dave Rahardja
                        >
                        >
                        >
                        >
                        >
                        <drahardja_atsi gn_pobox_dot_.. .@pobox.comwrot e:
                        >
                        I especially like
                        >
                        class B
                        {
                        public:
                        virtual void foo() {}
                        >
                        };
                        >
                        class D: public D
                        {
                        public:
                        virtual void foo(): B {}
                        >
                        };
                        >
                        It's clean.
                        >
                        Microsoft (VC 8) already allows B::foo(). ie:
                        >
                        class D: public B
                        {
                        public:
                        virtual void B::foo() {}
                        >
                        };
                        >
                        if B does not have a matching foo, it issues an error.
                        >
                        -dr
                        >
                        Tony- Hide quoted text -
                        >
                        - Show quoted text -
                        Yea VC 8 has really some new useful improvement in both language and
                        syntax.

                        In the case of overriding they have introduced some new keywords,
                        clean and elegant syntax.

                        http://msdn2.microsoft.com/en-us/library/4dd87x3d.aspx
                        http://msdn2.microsoft.com/en-us/library/fw0bbh51.aspx

                        Comment

                        • Pete Becker

                          #13
                          Re: Explicit Virtual Functions

                          Dave Rahardja wrote:
                          On 4 Mar 2007 05:52:40 -0800, "Sarath" <CSarath@gmail. comwrote:
                          >
                          >On Mar 4, 6:49 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
                          >>Sarath wrote:
                          >>>Hi All,
                          >>>Could you please give some good links to learn about the "Proposed new
                          >>>syntax for Virtual functions" in the new standard?
                          >>>If you could explain it in simple manner as a reply that will be very
                          >>>helpful. I just referred Wikipedia for the same. But still looking for
                          >>>a simple description for same.
                          >>>Regards,
                          >>>Sarath
                          >>This is official
                          >>>
                          >>http://www.open-std.org/jtc1/sc22/wg...006/n2108.html
                          >>>
                          >>and seems easy enough. It's just a machanism for avoiding mistakes when
                          >>writing a derived class.
                          >>>
                          >>Can't say I like it very much at first glance.
                          >>>
                          >>john
                          >>
                          >I'm really confused with one of the explanation I found in Wikipedia
                          >http://en.wikipedia.org/wiki/C++0x#E...tual_functions
                          >>
                          >I think these are ablsolutely different one.
                          >
                          Is there really a need for controlling which virtual functions can be
                          specialized? What is the class of problems that this is supposed to solve?
                          >
                          Despite it's misuse in that article, "specialize d" is not the right
                          term. A function with the same signature as a virtual function in a base
                          class overrides that function.
                          I think that a syntax addition that explicitly indicates that a derived class
                          is specializing a base class's virtual function is very useful. The absence of
                          such indications should result in a warning only (to preserve compatibility
                          with old code).
                          >
                          I especially like
                          >
                          >
                          class B
                          {
                          public:
                          virtual void foo() {}
                          };
                          >
                          class D: public D
                          {
                          public:
                          virtual void foo(): B {}
                          };
                          >
                          >
                          It's clean.
                          >
                          Yup. And you'll have lots of fun playing "Mother, may I?" with the compiler.

                          --

                          -- Pete
                          Roundhouse Consulting, Ltd. (www.versatilecoding.com)
                          Author of "The Standard C++ Library Extensions: a Tutorial and
                          Reference." (www.petebecker.com/tr1book)

                          Comment

                          • tragomaskhalos

                            #14
                            Re: Explicit Virtual Functions

                            On Mar 6, 8:16 am, "Sarath" <CSar...@gmail. comwrote:
                            Yea VC 8 has really some new useful improvement in both language and
                            syntax.
                            >
                            In the case of overriding they have introduced some new keywords,
                            clean and elegant syntax.
                            >
                            http://msdn2.microsoft.com/en-us/library/4dd87x3d.aspx
                            http://msdn2.microsoft.com/en-us/library/fw0bbh51.aspx
                            >
                            Big caveat here : Microsoft are notoriosly bad at distinguishing
                            between C++ and C++/CLI in their documentation.
                            These links seem to refer to C++/CLI.

                            Comment

                            • Dave Rahardja

                              #15
                              Re: Explicit Virtual Functions

                              On Tue, 06 Mar 2007 07:15:29 -0500, Pete Becker <pete@versatile coding.com>
                              wrote:
                              >Is there really a need for controlling which virtual functions can be
                              >specialized? What is the class of problems that this is supposed to solve?
                              >>
                              >
                              >Despite it's misuse in that article, "specialize d" is not the right
                              >term. A function with the same signature as a virtual function in a base
                              >class overrides that function.
                              You're right. It's override, not specialize.
                              >
                              >I think that a syntax addition that explicitly indicates that a derived class
                              >is specializing a base class's virtual function is very useful. The absence of
                              >such indications should result in a warning only (to preserve compatibility
                              >with old code).
                              >>
                              >I especially like
                              >>
                              >>
                              >class B
                              >{
                              >public:
                              > virtual void foo() {}
                              >};
                              >>
                              >class D: public D
                              >{
                              >public:
                              > virtual void foo(): B {}
                              >};
                              >>
                              >>
                              >It's clean.
                              >>
                              >
                              >Yup. And you'll have lots of fun playing "Mother, may I?" with the compiler.
                              This argument can be said about many features that enforce tighter semantic
                              controls in the language. Truth be told, I have encountered so many errors in
                              which the author of a derived class /thought/ that he'd overridden a virtual
                              function in a base class, but actually created a slightly different version
                              instead. Hours of fun debugging ensued. The explicit syntax would be helpful.

                              I suppose the warning could be restricted to the occasions where you are
                              hiding a base class virtual function by defining a function of the same name
                              (but with different parameters) in the derived class. That way classes that
                              /correctly/ override base class virtual functions will not generate warnings.

                              -dr

                              Comment

                              Working...