Nested functions

Very true. Manipulation of thread-local storage is the reason why displays,
after the early Algol implementations, have never been in favour with
compiler writers. The first generation of Modula-3 compilers (with C
backends) generally opted for inlining nested functions. Nowadays the use of
static links is the only game in town.

llvm makes this difficult as the static link technique obliges to reify
stack frames as structures in order for individual entries to be accessible
through the "getelementptr" instruction. This becomes very unwieldy in the
case of a large nesting tree (nested function may also call each other at
intermediate levels). While llvm's ban on pointer arithmetic _is_ a good
thing (TM), it has also its drawbacks.

We should not single out the case of shallow nesting, which can be easily
optimised away through lambda lifting etc. I know about whole language
front-end parsers where the grammar is reflected through a huge tree of
nested functions. These are the only occasions, beside container mapping
functions, where the use of nested function becomes really interesting and a
thoroughly clean implementation becomes a must.

The fact remains that Pascal and Modula features such as lexical nesting are
generally shunned upon by the C subculture and thus receive a poor deal in
the world of open software where there is no life beyond GNU, C and Unix.

/dm