8 votes

C# declaration redundancy

Is there any benefit to the actual redundancy, or any risk on a more concise declaration that I haven't identified ? The C# language team have discussed removing the need for that redundancy by ...
David Arno's user avatar
  • 39.3k
6 votes

Regarding a variable in C, is an assignment always equivalent to a definition of that variable?

C++ Oddly enough, C++ is actually rather simpler than C (in at least some respects) when it comes to declarations vs. definitions, so let's start with it. Declaration In C++, a variable declaration ...
Jerry Coffin's user avatar
  • 44.5k
4 votes
Accepted

Is interleaving local variable declarations with assertions and function calls a bad practice?

Is there a reason not to do this? Tradition. Stupid as it sounds we were forced to do things in certain orders in older languages and we're dragging those old, no longer relevant, habits around. ...
candied_orange's user avatar
2 votes

Regarding a variable in C, is an assignment always equivalent to a definition of that variable?

Is there a difference between defining a variable in C and assigning a value to a variable in C? You can only define a variable once but you can assign a variable multiple times. Conversely, ...
pjc50's user avatar
  • 13.4k
2 votes

How to compute whether it is guaranteed the variable is set?

What you're asking about is a form of data flow analysis. The code could be translated into some form of basic blocks (or other intermediate data structure). There will be flow of control (branches) ...
Erik Eidt's user avatar
  • 33.7k
2 votes

C# declaration redundancy

What changes you are suggesting for member variables is only a change in the compiler. There needs to be no change in the executing CLR. So such a change would be easy to bring. You would need to ...
Nachiappan Kumarappan's user avatar
1 vote

Scheme's define in Common Lisp

You don't have to use LET when using DEFUN: you can define local variables in the parameter list: (defun foo (a) (let ((b (expt a 3))) (+ a b))) is also (defun foo (a &aux (b (expt a 3))) ...
Rainer Joswig's user avatar
1 vote

C# declaration redundancy

The core idea I don't see an issue with using a syntax similar to var variables when declaring class variables: public class Foo { var Bar = new Bar(); } All the necessary information is there, ...
Flater's user avatar
  • 49.4k

Only top scored, non community-wiki answers of a minimum length are eligible