On Friday, 25 January 2013 at 19:30:41 UTC, Jonathan M Davis wrote:
On Friday, January 25, 2013 17:37:48 eles wrote:
On Thursday, 24 January 2013 at 08:35:01 UTC, Walter Bright
And why wouldn't setters be able to throw. Why on earth would you do other than throw in code like you have above? How on earth would a setter report a bad argument if it was forced to be nothrow? Exceptions are the correct solution. Setters _need_ to be able to throw. Plenty of them don't need to, but plenty of them do. For instance, many of the properties in std.datetime will throw if you give them invalid values (like setting the hour to 28). I don't see how you could possibly argue that a setter should not be able to
throw.

You are right. In fact, just after I post the message, I was hit by second toughts.

But a issue still remains: assignments of variables are not usually checked for exceptions. Programmers do not have in mind that they could trigger exceptions.

However, properties could do.

The danger that I see is that programmers will start to "preventively" check everything for exceptions, "just in case" that those current variable assignments would be latter turned into properties.

Do you feel like embracing all your code in try/catch?

Reply via email to