On 11/14/13 1:36 AM, monarch_dodra wrote:
On Wednesday, 13 November 2013 at 01:37:15 UTC, Jonathan M Davis wrote:
Except that pretty most of your examples don't seem like they would fail any
more than T.init would. int.max / 2 in so no more valid or invalid than 0. The
only difference I see would be that by setting pointers/references/arrays to a
weird value rather than null, they'll be treated as if they have a value and
then blow up rather than blowing up on a null value. For all the built-in
types, T.init is essentially supposed to be as invalid as the type can get
without pointing off into memory that it shouldn't be addressing.

So, the only thing I see that this suggestion does over using T.init is that
on pointers/references/arrays, you won't end up with code that checks for null
and avoids blowing up. Code that checks for null would then blow up just as
much as code that assumes that the pointer/reference/array was non-null. But
that's the only difference I see, since none of the other types end up with
values that are any more invalid than T.init.

- Jonathan M Davis

+1. Essentially, I don't see how any of this is better than .init.

What about user defined types? How do you want to deal with those? Recursively 
search all basic
types and set them to the above mentioned values?

It can be nice to distinguish between initial state and final state.

Reply via email to