[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Language War (Re: "C" Manual)



On Thu, Jan 03, 2002 at 07:04:38AM -0800, Eric G. Miller wrote:
| On Thu, 3 Jan 2002 09:31:16 -0500, dman <dsh8290@rit.edu> wrote:

| > However the thing to remember about macros is that they are textual
| > substituation.  It is effectively the same thing as writing the
| > assignment yourself.
| 
| Yes, but for a little block of code that you'd use often, you don't
| have to repeat it gadzillion times, and the result should be easier
| to read.

There are times when a macro is the best alternative, however it is
not part of the programing language itself.  (you can use macros in
java, if you run the source through a preprocessor before the java
compiler gets to it, in fact this is true of any textual data (ie
pipes and filters :-)))

| Problem is, these things can be abused.  Add a bunch of
| global data structs, and you've got a nearly impossible to maintain
| chunk of code...

Right.

| > | I've had occasion to use some replacement macros for malloc and realloc as
| > | well.  The realloc being the more useful.  Inline functions are
| > | cleaner though...
| > 
| > inline functions are really no better than macros, and can even cause
| > bugs (though surely that's just a sign of a buggy compiler).
| > 
| > For a particular school project (C++ required) the profs had a working
| > demo that we could run to verify our output (and clarify anything in
| > the specs).  They compiled it without debug symbols so we couldn't
| > look at it in a debugger and reverse-engineer it.  Their demo would
| > crash with certain malformed input.  One of the profs tried to figure
| > it out, but once it was recompiled with debug symbols (which also
| > turns off inlining, for that compiler at least) the program worked
| > correctly.  They had used inline functions extensively in their
| > code.
| 
| I think there are some subtle differences between inlining C++ and
| inlining C.  Since, I haven't done any C++ for a couple years, I
| was thinking in C.

IIRC C didn't have 'inline' until C99, though I think gcc implmented
it anyways.

| Well, can't say I've ever gotten into the habit of using "inline". 

Glad to hear that :-).

| It's just not portable enough in C

See above.

-D

-- 

A perverse man stirs up dissension,
and a gossip separates close friends.
        Proverbs 16:28



Reply to: