Tagged Questions
5
votes
1answer
377 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
432 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 ...
2
votes
1answer
212 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 ...
4
votes
8answers
343 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
6answers
468 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 ...
5
votes
4answers
743 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 ...
3
votes
7answers
1k views
How to abbreviate variable names
I always struggle in abbreviating variable names. Is there any standard for abbreviating variable names?
11
votes
6answers
587 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 = ...