On Fri, 27 Mar 2009 21:56:36 +0300, Steven Schveighoffer <[email protected]> wrote:
> On Fri, 27 Mar 2009 13:44:48 -0400, Nick Sabalausky <[email protected]> wrote: > >> "Simen Kjaeraas" <[email protected]> wrote in message >> news:[email protected]... >>> >>> I feel the problem here is that you can access a type's static members >>> through an instance of it, not so much the property syntax. >>> >> >> That didn't even occur to me. That's certainly a problem too. > > > Yes, that was my main beef with the compiler when I had to fix it. I'd > prefer static member functions not be callable on instances. On the other > hand, accessing static members is sometimes convenient: > > ReallyReallyLongStructName n; > n = n.init; > int x = 5; writefln(x.init); // prints 0; how is that possible? It should certainly be either disallowed or yield 5. int x = 5; writefln(typeof(x).init); // 0 as expected Now this one is fine. > Note that even with the poposed fix, this is valid code which makes for > much confusion: > > TimeSpan.fromSeconds = 30; > > Which essentially does nothing, but looks like it's setting a static > property. > > I agree with you that the designer of a class should be the one to define > its interface, not the user. I've always wished for the ability to > specify which functions should be properties and which ones should not. > > BTW, I think the way C# properties work with chaining is to do this: > > // a b c are properties > a = b = c = 42; > > translates to: > set_c(42); > set_b(get_c()); > set_a(get_b()); > > -Steve >
