Pronouns a new name for an old idea
In a sentence in natural language a thing can be referenced. The dictionary defines a 'pronoun' as
"a word that can function by itself as a noun phrase and that refers either to the participants in the discourse (e.g., I, you ) or to someone or something mentioned elsewhere in the discourse (e.g., she, it, this )."
In programming we often find that we have "variables with local scope" that are used within a block. They "refer" to other things. In Lisp, for instance, a LET construct will create local variables that disappear on exit:
(defun foo (x) (let ((y (first x))) ....
in C it might be
void foo (x) int y = first(x); ...
Here 'y' is local.
Rather than calling these "variables with local scope" I suggest we call them "pronouns".
12 comments
[ 2.5 ms ] story [ 38.5 ms ] threadJust calling everything a "variable" seems imprecise.
That's what they are, though, it is as precise as it needs to be. Why try to reinvent the wheel?
If anything, this is placing more emphasis on people with a more formal grasp on language. As a layman, I never thought this hard about pronouns, just associated them with the most common ones and didn't think more about it.
Local means close to, global means everywhere. Give a couple of code examples and I think we're cooking with gas.
I’m sorry, I don’t see the problem here.
'I identify as a random eight bit integer. To properly address me you'll need to buy this 5,000$ dongle that's synced up to my personal identity. It changes every 30 seconds.'
/s
There is a closer equivalent of pronouns in (some) programming languages, topicalizing variables. _ in Scala, $_ in Perl, % in the recent JS proposal for pipelines, etc., and the usual explanation of them links to pronouns (and the name links to a linguistic feature related to pronouns, that is also descriptive of their operation.)
The explicit definition of normal local variables make them unlike pronouns. They are more akin to in natural language, providing a description of, e.g., a hypothetical person and then “lets call her Alice”, which is not a pronoun, just a limited scope assignment of a name.
Variables are readily invented. By that alone we know they can't be pronouns.
You use variables in English when pronouns would cause too much ambiguity. For instance "Let's suppose that some company X owns 75% of another company Y, and that Y and X are both ... lorem ipsum yadda yadda".
Anaphoric macros like Paul Graham's aif introduce something like pronouns. They use some reserved words like it which are implicitly bound to some expression values or whatever.
The this symbol in C++ is obviously a pronoun of C++; it's named after a pronoun of English. It's a reserved word: you can't define a new thing like it in C++, so it checks off as a pronoun that way, and it implicitly refers to something, like a pronoun.