
Ask HN: Confused by a friend in discussion of variables (repost) - IAskForAFriend
I asked this a little while ago, but I didn&#x27;t get much of a response.  I&#x27;ll only ask it this once more in case people didn&#x27;t see it - having lurked here a while I know there&#x27;s a large dollop of chance in whether a post gets seen.<p>Anyhoo ...<p>A friend of mine is not a programmer, but does program.  My friend has a degree in mathematics, works in the supply of a specific type of computer hardware, uses Perl to accomplish various scripting tasks, and is very capable in doing so.<p>While discussing programming languages recently I casually said that we can think of &quot;variables&quot; as boxes to put things in with the name of the variable on the outside, and the thing we put in these boxes are &quot;values&quot;. &quot;Values&quot; can be complicated, and may actually be references to other things.<p>My friend went thoughtful, and then said:<p><i>Suppose I have a hash:</i><p><pre><code>    $next{&quot;thingy&quot;}=&quot;whatname&quot;;
    $next{&quot;whatname&quot;}=&quot;wotsit&quot;;
    $next{&quot;wotsit&quot;}=&quot;doohickey&quot;;
</code></pre>
<i>Then I would have said</i> (my friend said) <i>that:</i><p><pre><code>    $next{$next{$next{&quot;thingy&quot;}}}
</code></pre>
<i>is another name for &quot;doohickey&quot; and hence is a variable.</i><p>Is this a common point of view?<p>I&#x27;d appreciate any thoughts or feedback - perhaps my viewpoint is too narrow, or simply wrong.
======
cnocito
The hash table is not a good example, because a hash is not a variable, it is
a function.

F(x) = "doohickey" when x = "wotsit"

I think you guys are confusing variables and data types (or data structures)
too, they are different things.

~~~
IAskForAFriend
Would you not say that "next" is a variable, and the value, the thing, that
"next" contains is a hash? "Next" is, of itself, not a function, surely.

~~~
cnocito
It it isn't "next", it's next{x}. It's a function, not a variable.

------
al2o3cr
It's a little weird, but not without precedent - for instance, take a look at
"setf" found in most Lisps.

