🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #437

Re: Re^2: Can you nest subroutines in C?

#437
From: Wade Bickel
Date: Sun, 09 Jul 1989 10:56
49 lines
2870 bytes
adjg@softway.oz (Andrew Gollan) writes:
>No. The reason why C does not support nested functions is that it is
>a _bad_ idea. The worst piece of impenetrable rubbish I have ever tried
>to understand was written by Wirth in Algorithms + Data = Programs and
>purported to handle B-trees. It was made impossible to understand by the
>_complexity_ of the scoping considerations. C scoping is not perfect, maybe,
>but nested functions would only make it worse.

 
        I used that piece of code myself.  Never had any trouble understanding
how the scoping is use  Did you write your own replacement?  Without nesting
it must be more complicated.  I don't see what your probem was with the code,
since it worked perfectly as is out of the book
 
        As far as it being equally doable by the programmer in C, this is not
the case.  There is no good way to make the input parametersto a function
visable to sub-functions without duplicating them.  I can see a possible
compiler specific hack that might alleiviate this but this really should not
be considered.
 
        I've thought about this whole issue of "displays" and I don't believe
it is as bad as indicated.  Allowing one level of nesting would be a breeze,
and deeper nesting would only require a pointer list system.

 
        The way I see it is this.  If C supported nesting, the programer would
know the ramifications of using nesting; namely that each level deeper a
nested routine is, the less efficiently it can get at the globals at higher
levels.  I myself would probably never nest routines more than one level.  The
code generated by such nesting should be efficeint, using an address register
to hold a simple frame pointer  No one would have to use the feature, so it
would be a plus, with no deficits.
 
        Plese understand, I like C.  Since I'm mosly writing solo applications
or working with a few others on projects we expect no one else to have to
maintain, C is great.  My only point is it would be improved by adding a few
of the things Modula-2 has to offer.  I'd ike to see nesting and an equivalent
to the WITH statement.  Both these things would be advntagous without any
corresponding disadvantages.
 
                                                        Have Fun,
 
                                                                Wade.
 
l

UUCP: {nosc ucsd hplabs!hp-sdd}!crash!pnet01!wade
ARPA: crash!pnet01!wade@nosc.mil
INET: wade@pnet01.cts.com
Technical Details
Message-ID: <4586@crash.cts.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!gryphon!crash!pnet01!wade

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!gryphon!crash!pnet01!wade
From: wade@pnet01.cts.com (Wade Bickel)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Re^2: Can you nest subroutines in C?
Message-ID: <4586@crash.cts.com>
Date: 9 Jul 89 10:56:41 GMT
Sender: news@crash.cts.com
Organization: People-Net [pnet01], El Cajon CA
Lines: 49