1
vote
4answers
260 views

Is there a concept of a variable with phases of initialization: uninitialized, initializing, immutable?

I was looking at this thread on Stack Overflow and thinking about the functional programming I've been learning, and how immutability is so key there, and it occured to me that maybe some language has ...
5
votes
1answer
442 views

Do there exist programming languages where a variable can truly know its own name?

In PHP and Python one can iterate over the local variables and, if there is only once choice where the value matches, you could say that you know what the variable's name is, but this does not always ...
2
votes
7answers
506 views

Should I refactor single letter variables for constructs like pointer/structure names?

And No, i am not referring to single variables in loops or exceptions. Lets say pointer/struct names in large c ,c++ programs . Are there any languages where this type of naming is acceptable or is ...
3
votes
1answer
377 views

Giving variables default values vs. treating accessing an undefined variable as an error

Having messed around with several scripting languages and being a bit of a linguist, there seems to be a way to divide dynamically typed languages into two groups: languages that give variables a ...
5
votes
8answers
428 views

One-use variables - has any language ever had them?

A principle that I follow is that, when an identifier is established, it should be a signal to the reader that the value referred to is indeed an abstraction which will be used more than once. That ...
5
votes
5answers
512 views

Is it OK to use dynamic typing to reduce the amount of variables in scope?

Often, when I am initializing something I have to use a temporary variable, for example: file_str = "path/to/file" file_file = open(file) or regexp_parts = ['foo', 'bar'] regexp = new ...
8
votes
4answers
1k views

When would dynamic scoping be useful?

With dynamic scoping, a callee can access the variables of its caller. Pseudo C code: void foo() { print(x); } void bar() { int x = 42; foo(); } Since I have never programmed in a ...
5
votes
7answers
3k views

How to abbreviate variable names

I always struggle in abbreviating variable names. Is there any standard for abbreviating variable names?
10
votes
5answers
697 views

Does any programming language use variables as they're in maths?

In maths, a variable means you can put any number there, and an equation will still be true: root(square(x)) = abs(x) In programming languages, this is not so: a var can change. In Python: y = ...