Pronouns a new name for an old idea

5 points by daly ↗ HN
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 ] thread
What problem does this solve?
When teaching programming the concept of "local scope" seems hard to grasp for some people. The easy explanation is that a pronoun (usually) has a scope of a sentence or a paragraph.

Just calling everything a "variable" seems imprecise.

>Just 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?

Can't/shouldn't change an entire industry's vocabulary to help out some entry level programmers, who, if they took a little bit longer, would grasp the concept.

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.

Honestly I understand the scope think a lot better. I still have no real mental model of what a pronoun is. Didn't even know what one was until my daughter mentioned the term during her first year in school
Programming is hard to grasp for some people. Local scope is the least of their worries and is altogether not that hard to understand. The County::State::City analogy where every item is a Place is an easy introduction to the concept.
then I could see this suggestion used informally in a teaching context with a student that has their dominant understanding in the structure of language, otherwise not so much
Local variables versus global variables.

I’m sorry, I don’t see the problem here.

Hi, my name is -0.0f, I'm trans-integer, my pronouns are nan/inf and I'm nullsexual.
Close to that I thought of another satirical take on the bizarre world of declaring pronouns...

'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

> Rather than calling these "variables with local scope" I suggest we call them "pronouns".

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.

Pronouns are typically a closed lexical category in a language. The speakers of a language can introduce a new pronoun (conjunction, preposition, article, ...) only with tremendous difficulty and rarity.

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.