Shorter words for “expression”

Some common terms for programming languages vary widely in meaning, but at least one is understood across languages: virtually everyone agrees on “expression”.

Well, except in those communities that use the concept most. They have their own words for it. In Lisp, an expression is called a “form”; in the ML and statically-typed-functional-languages community, it's called a “term”. And let's not forget graph reduction, where it's called a “redex” (supposedly for “reducible expression”, although the “reducible” part is no longer relevant to the meaning). These terms all mean exactly the same thing, and all of the communities accept “expression” as a synonym, but they also have their own equivalents.

Private terms for common concepts usually exist to show group affiliation. That may be contributing here, but I think the main reason for replacing “expression” is brevity. It's difficult to write about programming languages (especially expression languages) without mentioning expressions exceedingly often, so there's a strong incentive to use a shorter word. “Expression” has three syllables and a difficult four-consonant cluster; “form” and “term” are easy one-syllable words. “Redex” is two syllables, which may explain why it's less popular than the other two.

None of the replacements are particularly transparent, but that doesn't matter much for such common words. (“Expression” doesn't make much sense either.) Apparently terms for such basic concepts needn't be obvious, as long as they're short.

Brevity may also be one of the reasons “thread” has largely replaced “process”. (The other reason is, of course, that popular OSes unify processes with other things like address spaces and security domains, and the word “process” has come to refer to the whole bundle rather than the original concept.)

2 comments:

  1. I think a Lisp form is more general than an expression; it's an expression giving rise to a value from the point of view of the Lisp parser, but not necessarily from the point of view of the programmer thinking at the semantic level.

    Conversely, I'd object somewhat to using 'term' as a synonym for expression. A factor is a piece of an expression split up at the multiplication level, while a term is a piece split up at the additive level. In "a*x + b", {a, x, b} are factors. The terms, meanwhile, are {"a*x", "b"}. But "a*x + b" is an expression.

    See e.g. http://www.tpub.com/math1/10a.htm etc. for more details.

    ReplyDelete
  2. In Common Lisp, at least, "form" pretty consistently means something to evaluate; a value that's read but not evaluated would usually be called a "sexpr" or "object". (The HyperSpec agrees with common usage.)

    The static-typing sense of "term" is probably derived from the standard math sense, but the meaning is different; in that community, it really does mean any expression, not just one that might be an argument of +. Despite that community's love of math, I don't think the redefinition causes much confusion, probably because the standard sense is a convenience rather than a name for an important concept. (Although these and other names-for-arguments like "numerator" and "exponent" are a whole class of terminological conveniences that hardly exist in programming languages, and maybe should.)

    (The previous comment didn't appear because it was stuck in the spam filter, which has so far not caught any actual spam.)

    ReplyDelete

It's OK to comment on old posts.