May 29, 2002 Properties in Interfaces? | ||||
---|---|---|---|---|
| ||||
How about allowing people to define properties as members of interfaces? This would allow people to use member-data style syntax for properties of interfaces, while still allowing it all to come through a vtable: interface MyIntf { void myProp(int val); int myProp(); } class MyClass : MyIntf { public: void myProp(int val); int myProp(); } class MyClass2 : MyIntf { public: int myProp; } MyIntf obj = new MyClass; MyIntf obj2 = new MyClass2; obj.myProp = 1; obj2.myProp = 2; printf("%d %d\n", obj.myProp, obj2.myProp); In order for MyClass2 to work, the compiler would have to generate wrapper accessor functions for the myProp property of that class, of course. However, MyClass could work without any compiler-generated code. -- The Villagers are Online! http://villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] |
May 29, 2002 Re: Properties in Interfaces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CF456D0.B775BF8E@deming-os.org... > How about allowing people to define properties as members of interfaces? This would allow people to use member-data style syntax for properties of interfaces, while still allowing it all to come through a vtable: > > interface MyIntf > { > void myProp(int val); > int myProp(); > } > > class MyClass : MyIntf > { > public: > void myProp(int val); > int myProp(); > } > class MyClass2 : MyIntf > { > public: > int myProp; > } > > MyIntf obj = new MyClass; > MyIntf obj2 = new MyClass2; > obj.myProp = 1; > obj2.myProp = 2; > printf("%d %d\n", obj.myProp, obj2.myProp); > > In order for MyClass2 to work, the compiler would have to generate wrapper accessor functions for the myProp property of that class, of course. However, MyClass could work without any compiler-generated code. > > -- > The Villagers are Online! http://villagersonline.com > > .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] > .[ (a version.of(English).(precise.more)) is(possible) ] > ?[ you want.to(help(develop(it))) ] > I know Delphi supports this kind of construction and I think it is also in the IDL spec. Seems good enough of an idea to me! -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail |
Copyright © 1999-2021 by the D Language Foundation