Five-dollar words for programmers: elision

Good writers borrow from other writers. Great writers steal from them outright. -- Aaron Sorkin1

Computer programmers have a habit of taking jargon from one area of study and borrowing it for use in their own. Today's five dollar word for programmers is elision; the verb form is to elide. This term from linguistics is used in two non-standard ways by computer programmers.

In natural language linguistics, elisions are the removal of sounds from spoken words that do not change their meaning. Saying

I'm gonna eat my vegtables.

instead of

I am going to eat my vegetables.

elides a great many sounds but does not change the meaning.

A less common usage of the term "elision" in natural linguistics is the omission of entire words. Many of my friends from Pennsylvania, for example, tend to elide the words "to be" from sentences that would require them in the Queen's English, like "do you have any towels that need washed?"

It is in this sense that computer language designers have borrowed the term: an elision in an programming language is when the language makes optional what might be thought of as a necessary portion of the grammar.

There are a number of legal elisions in C#. For example, the accessibility modifier private may be elided almost everywhere; you can usually remove private from a declaration without changing the meaning of the program. All versions of C# allow you to elide the array bounds and array type in a local variable initializer. These are all the same:

int[] x = { 10, 20, 30 };
int[] x = new int[] { 10, 20, 30 };
int[] x = new int[3] { 10, 20, 30 };

And C# 3.0 and higher also allow

int[] x = new[] { 10, 20, 30 };

I said there were two ways in which computer programmers co-opt the word; the second is in optimization theory. As we just saw in my long series on optimizing lifted arithmetic, the optimizer is allowed to elide conversions if it knows that they are unnecessary: in an expression where an int? is added to an int, by rights we ought to be implicitly converting the non-nullable integer to a nullable integer. But the compiler knows that doing so is a pointless waste of time because the conversion can be removed without changing the meaning of the program. Or, as I described back in 2010, the compiler will sometimes elide the creation of a temporary when initializing a local variable of value type. This form of elision optimization is called copy elision.

Next time on FAIC: Integer arithmetic can be tricky. We'll try dividing two numbers and see what happens.

  1. Sorkin was of course stealing outright from T.S. Eliot, who in 1920 wrote:
    Immature poets imitate; mature poets steal; bad poets deface what they take, and good poets make it into something better, or at least something different. The good poet welds his theft into a whole of feeling which is unique, utterly different than that from which it is torn; the bad poet throws it into something which has no cohesion. A good poet will usually borrow from authors remote in time, or alien in language, or diverse in interest.

    Sorkin's pithy summary, or a slight modification of it, is often attributed to Pablo Picasso and Oscar Wilde, but I've found no reliable evidence that either man ever said anything like it. See this blog post for details.

18 thoughts on “Five-dollar words for programmers: elision

  1. Funnily enough, while it's not a word I use *often*, I used it just in the last week for Noda Time. We have the concept of a ZoneInterval: a portion of a time zone where everything is the same, i.e. between transitions. While the typical transition is between daylight saving time and standard time, it's possible to have transitions which either *just* change the name, or perhaps change the balance of standard offset vs savings offset, while keeping the same overall (wall) offset.

    In ZoneEqualityComparer ( I allow two consecutive zone intervals to be "elided" if they only differ in ways we don't care about for the purposes of equality. The elision is only temporary, so it doesn't matter which values we take for the properties we don't care about - the result is one ZoneInterval.

    Does this seem a reasonable use of "elide" to you? It feels very much like the linguistic "gonna" version... (I use the term in doc comments, so if I'm using it inappropriately, I'd love to correct it now...)

  2. And up in the IDE, we have our own uses of the word "elision". The Visual Studio editor API has the concept of an elision buffer, which is a text buffer that contains only parts of another buffer (eliding the rest).

  3. And I guess, for those with a liturgical church background, praising God with fewer words would be... kyrie elision! : )

    [Perhaps there needs to be a comments filter to block terrible puns from being published on such a prestigious blog]

  4. I don´t like elisions in natural languages, but I certainly love the smart ones in C#.

    Thank you Eric

    • In addition to Eric's example, there is also the class declaration itself, where the absence of an accessibility modifier results in the class being "internal" rather than "private".

    • Another example is in a partial nested class. "private partial class A" and "partial class A" do not mean the same thing: "private partial class A" means "A is private, and it is an error if another partial declaration of class A specifies different accessibility", while "partial class A" means "A is private, unless another partial declaration of class A specifies the accessibility". Of course, Eric's note does apply here too: "private partial class A" is only legal in those projects where no other partial declaration specifies a different accessibility, so this does not affect a correct C# project. It only changes the meaning of a single valid declaration inside that project.

  5. And C# 3.0 and higher also allow
    int[] x = new[] { 10, 20, 30 };

    No doubt there are good reasons for it, but unfortunately outside of initializers, this variant is as close as we can come to the most concise initializer syntax that's permitted (i.e. just "{ 10, 20, 30 }" without "new" or any of the other stuff).

  6. Pingback: The Morning Brew - Chris Alcock » The Morning Brew #1281

  7. Pingback: Liens de la semaine – #15 | frenchcoding

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>