@property - take it behind the woodshed and shoot it?
Rob T
alanb at ucora.com
Fri Jan 25 12:01:02 PST 2013
On Friday, 25 January 2013 at 19:50:23 UTC, eles wrote:
> On Friday, 25 January 2013 at 16:48:21 UTC, Simen Kjaeraas
> wrote:
>> On 2013-37-25 17:01, eles <eles at eles.com> wrote:
>>
>>> On Thursday, 24 January 2013 at 08:35:01 UTC, Walter Bright
>>> wrote:
>> But setting the hours field to 28 is natural? While I want all
>> properties to be safe nothrow pure, it is unlikely to be a good
>> idea to force this upon people.
>>
>> I'm all for putting it in the style guide, though.
>
> See this answer here:
> http://forum.dlang.org/post/mdhvjbjqryzjljzqleay@forum.dlang.org
>
> The problem is that programmers would start feeling like "it's
> better" to check every assignment for exceptions, in the case
> that the variable is latter converted into a throwing property.
>
> I have no solution to that, though...
>
> OOH, I feel it will lead to bad programming style. OTOH, I feel
> like masking a database interrogation behind a property will
> throw some exception sooner or later.
>
> So, I am clueless.
You can easily wrap all of your functions in a try catch block
that will act as a safety net and catch all potential Exception
throws.
Unfortunately I don't know if there's a performance hit with
wrapping up all functions in this way.
--rt
More information about the Digitalmars-d
mailing list