Hi Maurizio,

Readonly members are implicitly initialized (all memory is zeroed before
it is used) but since readonly members can't be set anywhere except for
in the initializer or constructor a warning is given.

The compiler will actually give an warning if you never initialize a
field but it won't give you an warning if you initialize it *somewhere*
(doesn't have to be the constructor).

So the C# semantics for all fields appear to be that a warning is given
if it is read *somewhere* but is never assigned a value *somewhere*.

^Tum


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:mono-list-
> [EMAIL PROTECTED] On Behalf Of Maurizio Colucci
> Sent: Sunday, 8 June 2003 2:59 a.m.
> To: mono-list
> Subject: Re: [Mono-list] Suggestion: warning "member variable not
initialized"
> 
> On Saturday 07 June 2003 16:03, Thong (Tum) Nguyen wrote:
> > Members are implicitly initialized to 0 or null so they do have a
> > meaning even if you don't explicitly initialize them...
> >
> > ^Tum
> I see. :-P
> 
> So the semantics of readonly members is "members which are not
> implicitly initialized, and must be explicitly initialized in the
> constructor"... right?
> 
> So the C# semantics is itself error-prone, because implicit
> initialization is error-prone.
> 
> Of course we cannot change the semantics! :-) On the other hand, my
> suggestion as a warning might still be useful, maybe...
> 
> bye,
> 
> Maurizio
> 
> 
> 
> _______________________________________________
> Mono-list maillist  -  [EMAIL PROTECTED]
> http://lists.ximian.com/mailman/listinfo/mono-list


_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to