On Fri, 27 Mar 2009 18:53:51 +0300, BCS <[email protected]> wrote: > Hello Nick, > >> I don't mean to put words in the Tango crew's mouths, but IMO this >> piece from 0.99.8's changelog is a great demonstration of what's wrong >> with D's sloppy "accessor" syntax: >> >> ------------- >> tango.time >> * TimeSpan.seconds(ulong), etc. is now replaced by >> TimeSpan.fromSeconds(ulong), etc. The original form causes problems >> when people write code like: >> >> auto ts = TimeSpan.seconds(60); >> ts.seconds = 30; // you would think this would assign 30 seconds to >> ts, but >> what it does is create a >> // temporary and throw it away. >> ------------- >> The fact that D lets you freely switch between "foo(x)" and "foo = x" >> (at least when you're not using a return value from foo) implies that >> passing one argument to a function is, in the general case, >> conceptually related to assigning a value. And that is an absurdity >> and abuse of syntax on the same level as pretending that string >> concatenation is an "addition" or that outputting is a "<<", etc. >> >> And this "solution" that Tango was forced to use as a result of that >> kludge doesn't totally solve the problem since it leaves symantic >> gibberish like this as perfectly-compileable: >> >> ts.fromSeconds = 30; // WTF is that supposed to mean?!? But it >> compiles anyway! >> > > One option would be to only allow that fn = v syntax where fn returns void. > >
Obscure rule and a bad idea in general. This way you can't do "a = b = c = 42;"-style chaining.
