On 05/02/2014 12:33 AM, Daniel Goldman wrote: > This may seem a silly question to some, but I think naming conventions > are important. So, any advice concerning naming conventions for m4 macro > names, eg foo_bar, fooBar, Foo_Bar, FOO_BAR, etc? > > [A-Z_a-z][A-Z_a-z0-9]* is the requirement for m4 macro names, I hope I > got that right, :) so that is not my question.
Yes, you got that right. > > In cpp, the strong standard is UPPER_CASE, such as: > > #define ANALYZES_AGES_UNDER_ONE__________TF FALSE > > Of course cpp doesn't care, allows same names as m4. But it is > reassuring to always see UPPER_CASE, a dead giveaway for cpp macros. > > In the GNU m4 manual, all the builtin macros are lowercase, and the > examples almost all use lowercase macro names. But an example from the > Gnulib project uses uppercase. sendmail seems to use at least a few > uppercase macros, maybe a lot. Some postings on this group use uppercase > names. My cpp experience makes me want to use UPPER_CASE. Is there any > general guideline, or is it just "whatever you like"? If no general > guideline, should there be? m4 is used in so many different contexts, and the language itself doesn't care, so it is really up to your application to choose a convention. But yes, autoconf recommends ALL_CAPS, or possibly sig_ALL_CAPS (where sig_ represents a lowercase namespace for a set of macros provided from a single source), as the easiest to recognize. Although the builtins default to lower case, m4 lets you rename the builtins to whatever naming convention you'd like. > > Could one argue builtins behave like "functions" (I know they are > macros), so maybe use lower_case for user-defined macros with "function" > behavior (just like some C lowercase macros, eg, isascii), and use > UPPER_CASE for "pure" macros (simple substitution)? Again, that's more up to your project, and what you want to document and maintain for your local use of m4. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature