Liste des Groupes | Revenir à cl c |
On 22/04/2025 22:03, bart wrote:
Too few levels of functions and/or macros (there is no semantic difference between macros and functions in this matter)There is a great deal of difference. Functions tend to be well-formed in their inputs and outputs.
What's your initial opinion of this 500-line example:I did ask at one point whether anybody could link to some truly terrible C code; nobody has so far.There are probably two reasons for that. One is that everyone, except perhaps you, understands that this is very subjective. I've seen plenty of code posted in this group, written by regulars whose programming skill and knowledge I highly respect, and yet which I would classify as "truly terrible" and reject it immediately if it were presented to me for code review in my work. The other reason is that nobody else is particularly interested in seeing bad code, or going out of their way to look for it.
>Why?
I just want to find out the threshold at which some will actually agree that macros have been abused or their use is over the top and unjustified.
>
We are all going to have different first-glance opinions on different bits of code.
But to form a solid, justifiable opinion I would want to see a lot more of the code in question.Suppose this is a class of program which you have extensive experience of writing, but you see extra layers of complications that you'd never needed in yours, and the other program doesn't work any better either.
OK. I haven't been able to find a limit for nested, non-recursive macros. And I don't know how to set up a test for recursive macros (I'm not even sure they exist in C).> but you're not considering howNo.
> bizarre and crippling restriction it would be to put a cap on it.
>
There WILL be a cap.
Very few things in this world are black-or-white.By the 500 such macro definitions, and the EXTENSIVE use of such macro invocations instead of functions, in a class of application I'm very familiar with.
Some deep nesting might be justified in special cases, for example some recursive macro that builds a string a character at a time.How do you know that?
>
But this was not such a case; it was simply decided to make it work using macros instead of functions.
Near 40 years' experience of implementing interpreters? On some very resource-limited systems too. Ones that have always run rings around other products, until more recently when people are trying harder.>And how do you know that is a good choice, or would be better in this case?
As for being crippling: I've written all sorts of language apps, including interpreters like this, without ever using more than one level, and for several decades, zero levels.
>
C ones are.A language like C provides all these odd-ball features, people are going to use them.Macros are hardly odd-ball.
Les messages affichés proviennent d'usenet.