Re: nested functions

Chris Dollin <>
8 Sep 2006 12:25:10 -0400

          From comp.compilers

Related articles
[7 earlier articles]
Re: nested functions (Marco van de Voort) (2006-09-06)
Re: nested functions (Tommy Thorn) (2006-09-06)
Re: nested functions (Jatin Bhateja) (2006-09-08)
Re: nested functions (Karsten Nyblad) (2006-09-08)
Re: nested functions foobar@nowhere.void (Tommy Thorn) (2006-09-08)
Re: nested functions (2006-09-08)
Re: nested functions (Chris Dollin) (2006-09-08)
| List of all articles for this month |

From: Chris Dollin <>
Newsgroups: comp.compilers
Date: 8 Sep 2006 12:25:10 -0400
Organization: HP labs, Bristol
References: 06-08-140 06-09-010
Keywords: functional, design
Posted-Date: 08 Sep 2006 12:25:10 EDT

Jatin Bhateja wrote:

> According to me GCC nested functions are not same as nested functions
> in functional languages as these languages are dynamically scoped
> languages

What functional languages are you thinking of? The ones with which I
have some familarity (ML, Scheme; Haskell, Miranda) are statically
scoped. Common Lisp is statically scoped except for variables
explicitly declared otherwise, if I recall correctly. [Emacs Lisp,
again if I recall what I've been told correctly, is dynamically

> and in them the order in which locals are searched is from
> inner to outermost function in enclosing order in run time stack. This
> could be implimented by using either Displays or by following the
> static link in activations records at run time.

Those two have different effects. If you just look up the run-time
stack you'll get dynamic binding, but if you use displays/static links
you'll get static binding.

[Sketch example:

        function outer( callMe: ItsType ) ...
                val v = ...
                function inner ... refer to v ...
                ... outer( if someCondition then callMe else inner )
                ... callMe( ... ) ...

When `outer` calls `callMe` and that's a version of `inner`
it should refer to the version of `v` associated with that
`inner` and not some more deeply-nested one (coming from the
`else` part of the conditional expression).

Chris "with one mighty lexical bound he was free" Dollin
"No-one here is exactly what he appears." G'kar, /Babylon 5/

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.