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 ...
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 ...
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. ...
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, ...
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) ...
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 ...
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)))
...
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, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
declarations × 16c × 6
variables × 6
coding-style × 4
c# × 2
loops × 2
initialization × 2
java × 1
object-oriented × 1
c++ × 1
programming-practices × 1
programming-languages × 1
performance × 1
language-design × 1
compiler × 1
clean-code × 1
windows × 1
functions × 1
debugging × 1
data-types × 1
parameters × 1
lisp × 1
io × 1
definition × 1
scheme × 1