Article View: comp.sys.amiga.tech
Article #328Re: Can you nest subroutines in C?
From: Mike (I'll think of something ye...
Date: Mon, 03 Jul 1989 20:29
Date: Mon, 03 Jul 1989 20:29
32 lines
2182 bytes
2182 bytes
In article <212@hitech.ht.oz> clyde@hitech.ht.oz (Clyde Smith-Stubbs) writes: <In article <603@laic.UUCP>, darin@nova.laic.uucp (Darin Johnson) writes: <> > I do not understand why C does not support Nested routines. Perhaps <> >this will be added to the ANSI standard at some point in the future. < <[Description of problem of references to variables that don't exist anymore.] < <The only way around it I could think of was to enforce some compile-time <constraints on what you could do with pointers. This is the hack solution. It's much better to cause function references to include the state of the "dynamic" variables when you save the pointer. This gets rid of a wart (that strange restriction), and allows for some very elegant solutions to problems. <In short, I see nested functions as practical to implement in C; there are <certain cases where nested functions can make a solution to a problem much <more elegant than is currently possible. Most (all?) of those cases are actually handled even more elegantly with a real data abstraction rather than these scoping rules. The only possible exceptions I know of mimicing dynamic scoping. The community that loved dynamic scoping has largely given up on it, but kept a mechanism around (variables that are dynamically scoped) to handle those cases where it's really needed. <mike -- I'm gonna lasso you with my rubberband lazer, Mike Meyer Pull you closer to me, and look right to the moon. mwm@berkeley.edu Ride side by side when worlds collide, ucbvax!mwm And slip into the Martian tide. mwm@ucbjade.BITNET
Technical Details
Message-ID:
<25989@agate.BERKELEY.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!eris.berkeley.edu!mwmReferences:
<4501@crash.cts.com> <603@laic.UUCP> <212@hitech.ht.oz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!eris.berkeley.edu!mwm From: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) Newsgroups: comp.sys.amiga.tech Subject: Re: Can you nest subroutines in C? Message-ID: <25989@agate.BERKELEY.EDU> Date: 3 Jul 89 20:29:15 GMT References: <4501@crash.cts.com> <603@laic.UUCP> <212@hitech.ht.oz> Sender: usenet@agate.BERKELEY.EDU Reply-To: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) Organization: Missionaria Phonibalonica Lines: 32