Re: I think C# is forcing us to write more (redundant) code



Neo The One wrote:
I think C# is forcing us to write more code by enforcing a rule that can be summarized as 'A local variable must be assgined *explicitly* before reading its value.'

If you are interested in what I mean, please look at this feedback my me:

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=3074c204-04e4-4383-9dd2-d266472a84ac

If you think I am right, please vote for this feedback.

Thanks.


Since the local variables are not guaranteed to be initialized to anything specific, moving this to a warning will guarantee that there's a lot of projects that will have strange crashes.


Since .NET has mechanisms built in to make sure data is always valid, and never inconsistent or corrupted (hence the need to initialize local variables), a warning will never be enough as a warning can be ignored, with unforseen consequences.

The effect on the garbage collector if you start to treat random memory adresses as .NET objects is probably the main reason for this.

So yes, I voted, but I voted 1.

If you want a change to the .NET compilers, you should add a suggestion that all local variables are zeroed out instead.
.




Relevant Pages

  • Re: MSEide+MSEgui rev. 0.9
    ... I have a lot of warning messages at compile time: ... local variables but, overall, "Warning, Class types xxx and yyy are ...
    (comp.lang.pascal.misc)
  • Returning pointers from functions
    ... when i compile the prog, the compiler gives me a warning regarding f2 ... saying that temp is a local variable and i m returning its address. ... the memory for the local variables can get overwritten anytime. ...
    (comp.lang.c)
  • Re: Where is my Class ?
    ... makes the object referenced by a (the anonymous class) accessible via the name B. After this, a and B are different names for the same object. ... In Ruby, constants, instance, and local variables are only names for objects. ... If you re-assign a constant, you get a warning, but the assignment happens nonetheless. ...
    (comp.lang.ruby)
  • Re: [PATCH] Dont compare unsigned variable for <0 in sys_prctl()
    ... it's often entirely interesting to hear about local variables ... way that gcc implements it, it's almost totally useless in real life. ... simply SERIOUSLY WRONG with the warning. ... the C language has scoping rules for a reason. ...
    (Linux-Kernel)
  • Re: D-M Quilting System - long rant
    ... Why don't you post the whole sorry story as a WARNING on every textile NG ... > the machine off the table and stitch, moving the fabric, it's fine. ... and certainly did not quilt like he stated it would. ... is that my parents gave me half the money. ...
    (rec.crafts.textiles.quilting)

Loading