gotchaMinor
Difference between free and global variables
Viewed 0 times
globalfreedifferencebetweenvariablesand
Problem
Is there any difference between free variable and global variable? Or they are just synonyms? In which situations I should use one or another?
Solution
They don't play in the same category.
The notion of free variable is relative to a scope. If a variable is present in a term (i.e. a subprogram) and its scope is larger than this term, then the variable is said to be free in that term.
A global variable is one whose scope is the whole program, or the whole file, or the whole module, or whatever scope is called “global” in the programming language you're considering.
The notion of free variable is relative to a scope. If a variable is present in a term (i.e. a subprogram) and its scope is larger than this term, then the variable is said to be free in that term.
A global variable is one whose scope is the whole program, or the whole file, or the whole module, or whatever scope is called “global” in the programming language you're considering.
Context
StackExchange Computer Science Q#14038, answer score: 9
Revisions (0)
No revisions yet.