3 ms·
This is why we call these things "values" not "variables"
by dukerutledge 11y ago
This is why we call these things "values" not "variables"
- mbrock 11y agoThose are different concepts. Variables have names, values typically don't. 500 is a value; foo is a variable.
- seanmcdirmid 11y agoValues that have names are typically called objects (their identity isn't structural). Named values are necessary for having mutable fields (I.e. variables).
- mbrock 11y agoHmm, that doesn't sound right to me, at least not if "name" means "identifier" in the conventional sense (like foo). For example, stack-based languages can do field mutation without names.
- seanmcdirmid 11y agoDepends if we are talking about local stack or global heap state. If you just want to modify a register, then a locally bound name/index/stack pointer is sufficient. If you want heap allocated aliased (shared) state, you need globally unique names or addresses. The challenge is always with global state, hardly ever with locally scoped state.
- ajuc 11y agoValue is the thing associated with variable. Like 3 or "foo". Variable is just a name for value.