Added support for terminal comma#1
Conversation
These macros allow the user to pass a single value to all invocations of the user macro, and the *_I variants additionally pass the index of the invocation as an integer literal. This requires a list of predefined increment operations. Updated the documentation accordingly, and added an overview and a link to the µSer library to README.md.
5c5064e to
847c4ba
Compare
847c4ba to
45033b3
Compare
|
Thanks for the suggestion! I'll take a closer look later. One thing I noticed: C forbids identifiers starting with |
|
Will do, thanks. I wanted to see whether this fork was actively maintained before getting into it too much. I think ideally it would be good to make similar variants of the other MAP variants. Also, this doesn't just behave correctly with a terminal comma, it ignores ALL empty arguments , so maybe there is need to clearly document that difference in behavior. |
|
I come from a LaTeX macro programming background and only recently made a foray into C macros so I don't know the conventions. I think ideally there would be a distinct convention for private implementation details macros and public entrypoints. I think the standard says that underscore followed by a lowercase letter is not reserved, so one could consider naming public macros with the prefix |
a58dcb7 to
c1eee36
Compare
|
For C it's convention to only use uppercase letters in macros, to distinguish them from other identifiers, because macros have global scope. Maybe it would be a good idea to not provide macros like |
My primary experience is with CPython: CPython uses
Yes, that sounds like a good choice to me.
I was running it with gcc. I just tested it with clang and it works as expected. I'm not really sure how to install |
Let me explain a bit. See also: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ where I took the approach from.
|
|
Thanks for the detailed descriptions, that clears it up.
C has its own idiosyncrasies :) Here we do macros in all caps. To avoid all collisions with variables/functions, different naming schemes are used.
MSVC is the Microsoft Visual C++ compiler, it doesn't run on Linux. I implemented a simple automated test for the macros and managed to set up a Github Action that will automatically compile + test the code on a GitHub server on Linux, Windows and Mac using GCC, MSVC and Clang, respectively. If you merge my |
|
Thanks, will do. Do you want me to put my tests in |
|
Yes please... I used a code generator to produce long test cases to make sure it works with 365 arguments. That's probably not necessary with your part, so just add it at the top of the file to the "static" portion of C code. |
Terminal commas are nice for defining a macro like
but currently
MAP(f,a,b,c,)invokesf()one extra time. Sometimes it is impractical to modifyfto support this, so I definedMAP_ALLOW_TRAILING_COMMAthat skips empty arguments.