feature request: interfaces for properties

Henning Hasemann hhasemann at web.de
Tue Mar 6 05:50:26 PST 2007


It would be nice if members would behave like properties, so one could enforce
them with interfaces.
For example:

interface IHasFoo {
  int foo();
  void foo(int);
}

// This class fullfills the interface
class F1 : IHasFoo {
  int foo() { return 5; }
  void foo(int f) { };
}

// Would be nice to have this working too
class F2 : IHasFoo {
  int foo;
}

If thats too strange to you, maybe one could instead allow members
for interfaces like:

interface IHasFoo {
  int foo;
}

with F1, F2 fullfilling it.

I know that can be fixed with writing property methods around int foo,
but that looks a bit rediculus and requires renaming of that member.

Henning

-- 
v4sw7Yhw4ln0pr7Ock2/3ma7uLw5Xm0l6/7DGKi2e6t6ELNSTVXb7AHIMOen5a2Xs5Mr2g5ACPR hackerkey.com



More information about the Digitalmars-d mailing list