On 09/09/13 15:12, Daniel Murphy wrote:
"Jacob Carlborg" <d...@me.com> wrote in message
news:l0jrm7$3199$1...@digitalmars.com...

So what's wrong with this approach, that's already working today:

class Foo
{
     void foo ();

     void foo ()
     {

     }
}

void main ()
{
     auto foo = new Foo;
     foo.foo();
}

BTW, this feature was implemented because you asked for it.

--
/Jacob Carlborg

Whoa, I didn't think of applying that to member functions.  This seems like
the answer.  Put your variables and function prototypes at the top of your
class.  Done.

Problem -- what about:

    class Foo
    {
        // Declarations
        void foo();
        int bar(double n);

        // Definitions
        void foo() { .... }
        int bar(double n) { ....}

        // Whoops!  Forgot to include this one in the
        // declarations list, but it's still accepted
        // as part of the class
        void goo() { ... }
    }

A well-defined rule for separating out declarations and definitions would check for that and throw a compile error.

Reply via email to