Re: C macros
Frank Kolmann <[email protected]>
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <CAB-SQvjz4qxCtvYFCXwdZwjSQOqSDhwtzOw1bwSQmgN7TXy=Fg@mail.gmail.com> |
Hi Jevgeni Thank you for the information. No I am not joking. Did not K&R design C? Why have macros in C at all? (I am sure there are real reasons, just my knowledge is so limited) I am still trying to come to grips with macros in general. When I first saw C macros my immediate impression was 'who can devise a macro that will reliably do what is intended in all cases?' (and I still have same impression) (it is almost like having a unreliable compiler within a compiler) You, Barbara, Marc and others all warn about deviating from 'c style' including program structure and use of macros. To me I believe your warnings say more than you realise. eg the ++ operator, initially I thought it meant ?? = ?? + 1 however the power of ++ operator is way beyond +1, especially for pointers, Thank you I will take on board all your advices. So the end conclusion I am reaching is, there are reasons why C++ Java C# AWK et al compilers were designed and to accept C with all its warts and progress to newer compilers (as I am) and hopefully the programmer world will evolve to a brighter future. Also thanks Marc for the link to macro discussions. (just reinforced my prejudices) Frank >Subject: Re: C macros >From: Jevgeni Astanovski >Date: Fri, 4 Apr 2014 09:37:48 +0000 List-archive: > >Frank, I think that your reference to K&R is a joke. >K&R book is a book for learning language. It is not for learning style. >They used "forever" as an example what CAN BE done using #define >but they never said that it SHOULD BE done. Feel the difference. >I personally hate this sort of macros because they make program unreadable for others - >exactly what Barbara told you earlier. >So: think of the people who will read your code, use clear constructions >.... -- This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected] To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/c400-l or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected] Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.