Liste des Groupes | Revenir à l c |
On 22/04/2025 22:40, Kaz Kylheku wrote:Actually, I used macros all the time for certain things back in the day. For instance, I remember using some macros for an abstraction. Something like:On 2025-04-22, bart <bc@freeuk.com> wrote:Why use macros at all?On 22/04/2025 20:26, Kaz Kylheku wrote:>On 2025-04-22, bart <bc@freeuk.com> wrote:>>Or would you automatically say it was reasonable no matter how many>
levels there were, just to disagee with me and to side with a fellow C
programmer?
You're trying to say that C is a bad language because you can have
7 or more layers of macro expansion, but you're not considering how
bizarre and crippling restriction it would be to put a cap on it.
Here, I'm trying to determine if this is the poster's honest, objective
opinion, or whether they'd always going to be defend such code no matter
what.
I identified some macros in there that look gratuitous; you just snipped
that part.
>>but you're not considering how>
bizarre and crippling restriction it would be to put a cap on it.
There WILL be a cap. Some deep nesting might be justified in special
cases, for example some recursive macro that builds a string a character
at a time.
>
But this was not such a case; it was simply decided to make it work
using macros instead of functions.
If you're going to criticize the macros, then hold the code constant.
>
If it is a given requirement that some code is to be written or
generated, and we have some macros which do that, are those macros a
"good" or "bad" solution?
They might be a big deal in your own language, but in my experience, largely in C, they seem to cause nothing but grief.
Here, it produces neither faster code nor smaller.
It makes debugging, porting, or anything requiring deep understanding, a nightmare.
This project uses approx 500 macros that look like functions.
Les messages affichés proviennent d'usenet.