How Nested Functions Work, part 1

Walter Bright newshound1 at digitalmars.com
Mon Aug 31 10:37:29 PDT 2009


language_fan wrote:
> This seems more like an advertisement of D than practical new information 
> for compiler construction. Nesting functions is the basic feature of 
> functional languages. Moreover even procedural Algol based languages such 
> as Pascal have always supported them, too.

But not C, C++, Java, etc., so quite a lot of programmers have little 
experience with them, and even less understanding.

> This information is also 
> taught in basic university level compiler courses.

I bet only a tiny fraction of programmers have taken university compiler 
classes. (Also, they were not covered in compiler classes I took.) 
Consider also that the Java JVM doesn't support static links, and last I 
heard the .NET IL didn't, either.


> Now that I checked what wikipedia had to say to the matter, it also 
> seemed to mention D. Apparently 'c-like syntax' plus 'advanced feature 
> <foo>' always equals 'innovation'.


Nested functions aren't innovative; they just are apparently lacking in 
many other popular languages, and seem to confuse a lot of people. If 
you google it, you'll find there's a lot of programmer confusion about 
them. Hence an article as to how they work is in order.

In part 2, I'll cover innovative things D does with nested functions.



More information about the Digitalmars-d mailing list