digitalmars.D - Property and method groups
- Sjoerd van Leent (24/24) Jul 31 2009 It appears that there are really different discussions about properties....
- Jarrett Billingsley (15/38) Jul 31 2009 There is a discussion about letting properties look and act as much as f...
- Sjoerd van Leent (2/39) Jul 31 2009 It's nice to be repetitive and say the same things that should've been i...
- Jesse Phillips (4/13) Jul 31 2009 Sounds to me like you missed the beginning of the discussion:
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
Jul 31 2009
On Fri, Jul 31, 2009 at 5:37 AM, Sjoerd van Leent<svanleent gmail.com> wrot= e:It appears that there are really different discussions about properties. =There is a discussion about letting properties look and act as much as fiel= ds, and there is a discussion about calling member methods on returning str= ucts.I'd like to seperate these discussions. First, I don't think it is wise t=o 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 dif= ferent 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 { =A0 group bar =A0 { =A0 =A0 =A0int foo() =A0 =A0 =A0{ =A0 =A0 =A0 =A0 return 123; =A0 =A0 =A0} =A0 =A0 =A0void foo(int i) =A0 =A0 =A0{ =A0 =A0 =A0 =A0 // do something spectacular =A0 =A0 =A0} =A0 } } This could be called as: auto o =3D new A(); auto i =3D o.bar.foo; o.bar.foo =3D 123; Fun thing about groups is that it is much more flexible. For example, bas=ic 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. ;)
Jul 31 2009
Jarrett Billingsley Wrote:On Fri, Jul 31, 2009 at 5:37 AM, Sjoerd van Leent<svanleent gmail.com> wrote:It's nice to be repetitive and say the same things that should've been implemented in D1 already. :-)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. ;)
Jul 31 2009
On Fri, 31 Jul 2009 05:37:50 -0400, Sjoerd van Leent 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.Sounds to me like you missed the beginning of the discussion: http://www.digitalmars.com/webnews/newsgroups.php? art_group=digitalmars.D&article_id=94225
Jul 31 2009