On Fri, 22 Apr 2011 13:22:31 -0400, Steve Schveighoffer <[email protected]> wrote:
From: Robert Jacques <[email protected]>
[snip]
Forth, came the realization that in D2 'seconds' would probably be pure, which would cause s.seconds = 5 to be compiler error.

No, it wouldn't be an error. s.seconds(5) is exactly the same as TimeSpan.seconds(5), both would be callable as pure functions. In other words, s isn't actually passed to the function, it's just used as a namespace.

I apologize, pure alone wouldn't be enough to cause a compiler error. I was thinking of the fact that DMD could/does error on expressions which do nothing. However, pure wouldn't be enough to let the compiler know 'seconds = 5' does nothing. It would probably take a combination of const/immutable + pure + nothrow, for DMD to detect that s.seconds = 5 could not possible produce useful work, and therefore should error.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to