Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!cs.utexas.edu!uunet!mcvax!ukc!harrier.ukc.ac.uk!jrc From: jrc@ukc.ac.uk (John) Newsgroups: comp.sys.amiga.tech Subject: Re: Can you nest subroutines in C? Message-ID: <1701@harrier.ukc.ac.uk> Date: 30 Jun 89 13:59:48 GMT References: <4501@crash.cts.com> Reply-To: jrc@ukc.ac.uk (John) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 19 In article <4501@crash.cts.com> wade@pnet01.cts.com (Wade Bickel) writes: >.. I do not understand why C does not support Nested routines. .. I think it's because you need to maintain a display (or something like that) to resolve references to variables in enclosing procedures. C has a lean and mean close to the machine philosophy, which this would run counter to. It also causes all kinds of horrible problems if you want to have pointers to functions - if you save a pointer to a nested function in an array, then call it much later on from another part of your program, what should those external variable references resolve to? Should a pointer to function in fact be a structure containing the entire context of the function at the time the pointer was created? All very un C-like. There are two issues here - nested funtions and allowing references to parameters in enclosing functions. BCPL (:-) has nested functions, but not references to enclosing scopes (a nicer compromise, IMHO) John Cupitt