R
ritterhaus
I'm an unashamed C coder learning C#, and in my first 24 hours with
the language I've already found my first TIDL (thing I don't like),
the inane "error cs0165." I'm sure that this has been discussed and
argued over at great length, but I'm having trouble finding useful
information about why this is considered to be an error and not a
warning. The compiler is often not bright enough to account for the
application logic (flow analysis my eye) and I find that perfectly
valid, error-free pieces of code refuse to compile because C# thinks
I'm too stupid to assign to a local variable before I use it.
The fact is, in my very first C# program (rewriting one of the C
examples I teach with in class) I get this error in two places: both
times the code is perfectly good and the variables hold proper values,
but csc doesn't seem to think so. If this would compile with merely a
warning I could live with that, because unassigned variables are a
Very Bad Thing, but to stop the compile for spurious problems based on
faulty flow analysis seems to me to be overkill.
Is there any intelligent reason for this design, or any intent to
change it in the future? I don't like stray pointers any more than the
next guy, but by gum, when I assign to my variables I don't expect to
be told that they are "unassigned" by some lazy compiler that won't do
as its been told.
RR
the language I've already found my first TIDL (thing I don't like),
the inane "error cs0165." I'm sure that this has been discussed and
argued over at great length, but I'm having trouble finding useful
information about why this is considered to be an error and not a
warning. The compiler is often not bright enough to account for the
application logic (flow analysis my eye) and I find that perfectly
valid, error-free pieces of code refuse to compile because C# thinks
I'm too stupid to assign to a local variable before I use it.
The fact is, in my very first C# program (rewriting one of the C
examples I teach with in class) I get this error in two places: both
times the code is perfectly good and the variables hold proper values,
but csc doesn't seem to think so. If this would compile with merely a
warning I could live with that, because unassigned variables are a
Very Bad Thing, but to stop the compile for spurious problems based on
faulty flow analysis seems to me to be overkill.
Is there any intelligent reason for this design, or any intent to
change it in the future? I don't like stray pointers any more than the
next guy, but by gum, when I assign to my variables I don't expect to
be told that they are "unassigned" by some lazy compiler that won't do
as its been told.
RR