it

Anaphora, now there’s a word. It’s a grammer term: “The use of a word which refers to, or is a substitute for a group of words.” Pronouns for example. Programming languages spend most of their capital providing anaphoric devices. Local variables, functions, types are all examples of this.

I’ve always had an affection for scripting languages that take this heart. Languages that let you write things like this:

  open(file)
  read_line(that steam)
  match(pattern, that string);
  print the first match;

Expressions like “that stream” which or “that <type-name>” aren’t difficult for a compiler to figure out. An phrases like “the <ordinal> <type-name>” aren’t hard either. It’s a bit hard, but a lot more fun, if you allow the the universe of type-names to be a bit more flexible so that in that example “match” isn’t really a type; it’s a pseudo type naming the return value of the call done to match.

I also love the way this kind of stuff makes some people’s skin crawl while it makes other people grin with glee.

I was reminded of this by a little macro package for Common Lisp that gives the programmer a bit of anaphoric semantics. Instead of writing:

    (if (car x)
        (incf (car x)))

It lets you write

    (sif (car x)
         (incf it))

It’s a nice example of how it is fun to write in Common Lisp where you can invent and explore ideas like this. Note that incf is analagous to prefix ++ operator in C.

Leave a Reply

Your email address will not be published.