Original Closures

I didn’t learn the term ‘closure’ until maybe 1978. I’m having trouble remembering when the first time was I used a language with them. Simula maybe? It predates Algol 68 I assume (update Algol 68 had only limited closures; see comments).

The language implementor discovers them the moment he: 1) allows a function to be defined nested inside another function; 2) allows the inner function to access the locals of the outer function, and 3) let’s the programmer get a handle to the function, i.e. treat it like data. You can actually get most of the fun of closures without a garbage collector if your clever.

They had been an issue in Lisp for years, but I didn’t have any Lisp experiance until the mid 70s.

It’s interesting how many of these ideas are as old dirt.

0 thoughts on “Original Closures

  1. theo

    This reminds me of the “downward funargs” mystery. A few years ago Jamie Zawinski complained about the lack of downward funargs in java, but no-one I knew had heard of them. After some research, I discovered that it was a lisp term that refers to a limited type of closure, which provides the ability to pass functions as arguments. It’s “downward” because the function is being passed into a deeper scope. This is relatively easy to implement with lexical scoping because when the function is defined you can just save a pointer to the relevant place on the stack. I’m fascinated by these sorts of incomplete features: functions that are sort-of like data, but not exactly…

    Anyway, apparently Algol 68 had downward funargs but not full closures.
    best reference I can find is http://www.cs.nyu.edu/courses/spring02/G22.3130-001/local-variable-addressing.ppt

    (Upward funargs is of course the ability to use functions as return values, going up a scope. This is more tricky to implement with lexical scoping. You would need to save a copy of the environment elsewhere. Lisp 1.5 had upward funargs but they were closed in the environment in which the function was defined, rather than following lexical rules. Scheme seems the first language to have full
    lexical closures)
    http://wiki.cs.uiuc.edu/VisualWorks/Closures

Leave a Reply

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