Article View: alt.msdos.programmer
Article #1106Re: Newbie Wants Advice on C-Programming
From: Dave Tutelman
Date: Mon, 11 Jan 1993 13:18
Date: Mon, 11 Jan 1993 13:18
59 lines
3292 bytes
3292 bytes
In article <FISCHER.93Jan9030817@orange.iesd.auc.dk> fischer@iesd.auc.dk (Lars Peter Fischer) writes: > >>>>>> "Michael" == Michael Malak (malak@grebyn.com) >>>>>> "Lars" == fischer@iesd.auc.dk (Lars Peter Fischer) >>>>>> "John" == John MAX Skaller (maxtal@extro.ucc.su.OZ.AU) > >Michael> 1) It has structured syntactic blocks for constants, types and >Michael> variables. >... >John> Seems to me that the simple concept of >John> nesting the symbol table so that symbols go out of scope at the >John> end of the block is very nice. C and C++ have this, too. >Lars>Ah, yes, but Pascal goes further. I says First we define all the >Lars>Types, then all the Variables, then all the Functions, and so on.... >Lars>This is a real pain and >Lars>makes code for anything but toy programs very hard to read. My organization's coding standard (adopted explicitly to make our software easier to read and maintain) calls for declaring and initializing variables as close as possible to their point of first use. In the ability to meet this goal: C++ good. Pascal bad. >John> Dont quite agree. Many 'mess-arounds' in C could be avoided >John> if nested proceedures were supported. C's failure to provide them >John> possibly results from being designed with archaic architectures >John> in mind. Don't see what this has to do with hardware architectures, if that's what you meant. If "software architectures", I don't see any that Pascal supports and C++ doesn't; quite the contrary, actually. Perhaps you could elaborate. As someone who has a few years real-world programming experience with each of C and Pascal, the ONLY times I've ever wished for nested procedures in C involved a combination of: - Repetitive operations of the same pattern within a single function, that weren't repeated in any other function. - A lot of function-specific state information (i.e.- local variables) required for this operation... too many to make each one an argument of a procedure. In such cases, I use macros in C; not as elegant as nested procedures, but they do the job. I tend to trip over this about once every couple of dozen source files. The operation is never something significant to the functional decomposition of my design, just a convenience for a few pages of code. I've never encountered a difficulty in either functional or data decomposition that really mattered to my design, where C didn't solve it at least as well as Pascal. And I find that C++ provides the best safety features of Pascal (tight type checking) without the unnecessary and ugly restrictions that have led me to drop Pascal in those applications where I have a choice. Dave
Technical Details
Message-ID:
<1993Jan11.131838.12844@cbnewsj.cb.att.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!rutgers!att-out!cbnewsj!davetReferences:
<FISCHER.92Dec30223532@orange.iesd.auc.dk> <1992Dec31.043002.24014@ucc.su.OZ.AU> <FISCHER.93Jan9030817@orange.iesd.auc.dk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!rutgers!att-out!cbnewsj!davet From: davet@cbnewsj.cb.att.com (Dave Tutelman) Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.sys.ibm.pc.programmer,comp.lang.c++,comp.lang.c Subject: Re: Newbie Wants Advice on C-Programming Message-ID: <1993Jan11.131838.12844@cbnewsj.cb.att.com> Date: 11 Jan 93 13:18:38 GMT References: <FISCHER.92Dec30223532@orange.iesd.auc.dk> <1992Dec31.043002.24014@ucc.su.OZ.AU> <FISCHER.93Jan9030817@orange.iesd.auc.dk> Organization: AT&T Bell Labs - Lincroft, NJ Lines: 59