Which D features to emphasize for academic review article
F i L
witte2008 at gmail.com
Tue Aug 14 08:24:29 PDT 2012
On Tuesday, 14 August 2012 at 14:46:30 UTC, Simen Kjaeraas wrote:
> On Tue, 14 Aug 2012 16:32:25 +0200, F i L <witte2008 at gmail.com>
> wrote:
>
>> class Foo
>> {
>> float x; // I think this should be 0.0f
>> // Walter thinks it should be NaN
>> }
>>
>> In this situation static analysis can't help catch issues, and
>> we're forced to rely on a default value of some kind.
>
> Really? We can catch (or, should be able to) missing
> initialization
> of stuff with @disable this(), but not floats?
>
> Classes have constructors, which lend themselves perfectly to
> doing
> exactly this (just pretend the member is a local variable).
>
> Perhaps there are problems with structs without disabled default
> constructors, but even those are trivially solvable by requiring
> a default value at declaration time.
You know, I never actually thought about it much, but I think
you're right. I guess the same rules could apply to type fields.
More information about the Digitalmars-d
mailing list