Property and method groups
Jarrett Billingsley
jarrett.billingsley at gmail.com
Fri Jul 31 06:15:26 PDT 2009
On Fri, Jul 31, 2009 at 5:37 AM, Sjoerd van Leent<svanleent at gmail.com> wrote:
> 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.
Man, it's 2006 all over again!
http://www.digitalmars.com/d/archives/digitalmars/D/41903.html#N41905
And that thread was about - oh boy - properties. ;)
More information about the Digitalmars-d
mailing list