new DIP47: Outlining member functions of aggregates
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Mon Sep 9 06:51:11 PDT 2013
On 09/09/13 15:12, Daniel Murphy wrote:
> "Jacob Carlborg" <doob at me.com> wrote in message
> news:l0jrm7$3199$1 at 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.
More information about the Digitalmars-d
mailing list