Which D features to emphasize for academic review article
Mehrdad
wfunction at hotmail.com
Tue Aug 14 13:30:13 PDT 2012
On Tuesday, 14 August 2012 at 15:24:30 UTC, F i L wrote:
> 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.
C# structs, as you might recall, enforce definite initialization.
:)
We could do the same for structs and classes... what I said
doesn't just apply to local variables.
More information about the Digitalmars-d
mailing list