Property and method groups
Sjoerd van Leent
svanleent at gmail.com
Fri Jul 31 02:37:50 PDT 2009
It appears that there are really different discussions about properties. There is a discussion about letting properties look and act as much as fields, and there is a discussion about calling member methods on returning structs.
I'd like to seperate these discussions. First, I don't think it is wise to call a member on a returning struct, because of the expectation that the underlying object knows about the change. Thus is not true for a struct.
What I want to talk about is a completely different approach to the a.b.c problem, and with that I just make my own proposal, that is completely different from any other, which I call groups.
Suppose we have a rather big class with many methods and properties, this could come in handy. My idea is to introduce groups, in some ways similar to the idea of namespaces.
class A
{
group bar
{
int foo()
{
return 123;
}
void foo(int i)
{
// do something spectacular
}
}
}
This could be called as:
auto o = new A();
auto i = o.bar.foo;
o.bar.foo = 123;
Fun thing about groups is that it is much more flexible. For example, basic and advanced methods can be separated, etc.
Just my 2 cents
More information about the Digitalmars-d
mailing list