Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
Simen Kjaeraas
simen.kjaras at gmail.com
Sun May 19 10:45:55 PDT 2013
On Sun, 19 May 2013 19:12:15 +0200, Idan Arye <GenericNPC at gmail.com> wrote:
> It's a good practice to initialize references(and all other types of
> variables) as soon as possible - and if possible, right away in the
> declaration. If that reference started as null, it's safe to assume it
> was not possible to initialized it at declaration, so it was
> intentionally initialized with null(if there was no initialization Java
> would scream at you).
>
> Now, let's assume that reference was non-nullable. It is safe to assume
> that this change would not remove the obstacle that prevented that
> reference from being initialized right away in the declaration - so you
> still need to initialize it to something else - let's call that
> something `Nil`. Nil is an object that tells you that the reference has
> not yet been initialized.
Uhm, no. Nononono. No. This is a complete and utter fallacy. What you
have just done is define Nullable!(NonNullable!T). I should not have to
explain too closely why this is a bad thing and should not be done.
--
Simen
More information about the Digitalmars-d
mailing list