Null pointer dereferencing in D
monarch_dodra via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jun 14 11:43:39 PDT 2014
On Saturday, 14 June 2014 at 17:15:16 UTC, Dicebot wrote:
> On Saturday, 14 June 2014 at 16:41:46 UTC, monarch_dodra wrote:
>> ".init" should simply mean "the default bit state of the
>> object". Let's not make it into anything more complicated than
>> that.
>
> I guess this is the root of disagreement. There is no place in
> documentation that says that "T.init" is in any way unsafe or
> dangerous, I see it as a perfectly casual feature often used in
> any kind of generic code. Putting it in the same league as cast
> which is explicitly designed to punch holes in the type system?
> No way.
I'm not saying it's to punch holes in the type system, but (if
memory serves right), TDPL simply defines it as the default bit
pattern that gets written before constructors are called (ergo
default value when no constructors are called).
It's not unsafe, but it *is* a way to request an object
explicitly initialized to that "initial" state, which may not
actually be ready for use until a corresponding constructor is
called upon it.
Which is what "@disable this" does.
More information about the Digitalmars-d
mailing list