On Tue, 28 Aug 2012 22:08:11 -0700 Jonathan M Davis <jmdavisp...@gmx.com> wrote:
> On Wednesday, August 29, 2012 06:46:25 Tommi wrote: > > The weird thing is that you can use a member access operator with > > a pointer (without explicitly dereferencing the pointer first). > > Well, you clearly haven't done much pointers to structs in D, I indeed haven't :) Usually "ref MyStruct" is good enough for my needs. > or that > wouldn't be surprising at all. . always implicitly dereferences the > pointer, which pretty much makes the -> operator completely > unnecessary. > I always figured it was just the reference semantics for classes (and the optional "ref" when passing structs) that eliminated the need for ->. Probably 99+% of the time I use structs it's either a plain-old-struct or "ref MyStruct", so I assumed C-style "(*foo).bar" was good enough for the rare uses of "MyStruct*", and it never bothered me. But it's definitely pretty cool that dot still works even for pointers. It's awesome that D is still pleasantly surprising me :) Out of curiosity, what about "MyStruct**" or "MyClass*"?