Null references (oh no, not again!)
Nick Sabalausky
a at a.a
Wed Mar 4 21:44:29 PST 2009
"Walter Bright" <newshound1 at digitalmars.com> wrote in message
news:gon0i2$1nsp$1 at digitalmars.com...
> Ary Borenszweig wrote:
>> Walter Bright escribió:
>>> Ary Borenszweig wrote:
>>>> It's not like that. They don't require you to initialize a variable in
>>>> it's initializer, but just before you read it for the fist time. That's
>>>> very different.
>>>
>>> The only way to do that 100% reliably is to instrument the running code.
>>
>> Java does it on compile time.
>
> Java is a severely constrained language. Even so, how does it do with
> this:
>
> Foo f;
> if (x < 1) f = new Foo(1);
> else if (x >= 1) f = new Foo(2);
> f.member();
>
> ? (You might ask who would write such, but sometimes the conditions are
> much more complex, and/or are generated by generic code.)
>
I can't think of a single example of metaprogramming that would generate
that without also happily generating things that would leave f potentially
uninited.
More information about the Digitalmars-d
mailing list