Questions tagged [variables]
For questions about variables, named storage locations that hold a value, which can be changed during the execution of a program.
9
questions
20
votes
6
answers
7k
views
Why do some languages have both immutable "variables" and constants?
Some programming languages (Rust is one I can think of off the top of my head) provides mechanisms to have immutable variables but they also have constants. Isn't an immutable variable just a constant?...
8
votes
4
answers
2k
views
Why are mixed declarations more challenging to implement than forcing all declarations to be at the top of a scope?
C89 had a requirement that all declarations must appear at the top of the scope before any statements:
...
1
vote
1
answer
154
views
How does languages distinguish passing a parameter by value and reference, especially with non-parameter direct initializations in consideration?
Background
What I want is to make the behaviors of the following two pieces of code identical:
specifier x = getX();
doSomething(x);
...
6
votes
1
answer
260
views
What is the difference between having an auto type and having dynamic typing?
In C++, you can define variables with auto instead of giving it a default type such as int. Like this (where ...
11
votes
6
answers
2k
views
Early binding, mutual recursion, closures. Can I have all three?
Take this Python snippet of two functions that are mutually recursive and form closures:
...
5
votes
3
answers
215
views
Types and variables in a different namespace
What would it take to design a language that permitted construct such as below?
int int = 10;
Such a language would need to be able to infer contextually whether a ...
7
votes
9
answers
450
views
What syntax options exist for avoiding variable names colliding with keywords and built-ins?
Preamble
As you probably know, keywords are special reserved words in a programming language that have specific meanings and purposes and can’t be used for anything but those specific purposes.
An ...
6
votes
2
answers
233
views
Why do newer languages allow implicit variable declarations?
For me, one of the best things to happen to FORTRAN was the introduction of the LOGICAL*1 type.
I quickly discovered that putting ...
0
votes
2
answers
205
views
How to store variables in an interpreted language? [closed]
Say I'm making an interpreted language. What's the best way for me to store variable name/value pairs (or type/name/value triplets in the case of languages with typing)?