A cool idea, though the it's in need of some better examples to show its true power. Several of the examples can be accomplished with the traditional C preprocessor. For example:
Very interesting, thanks! Do you use many of these macros in your code? Does you find it makes it easier to read? I know some macro substitution can be impossible to read due to the CRAZY_CAPITALNAMES_THEY_GIVE_THEM
No, it's the head of a for-loop. (The statement or block that follows this macro invocation becomes the body of the loop.) The third clause of the loop head guarantees that the loop can execute at most once.
I misinterpreted it as some kind of readall | map online, with actual code as 2nd clause of the for loop; reading fp as short for function_pointer at first.
Using "continue" in that loop is harmless, it causes the file pointer to be closed and the loop to terminate. Calling "break" is more harmful though, as it would cause the loop to terminate without closing the file, a memory leak.
Just to completely hijack this whole thought... Bjarne S. has pitched 'smart references' as a library feature for C++, for the fourth time. Smart references require adding overload capability for operator..
It seems that by adding operator;, operator if, operator for, etc., we could use Veldhuizen-style expression-templates to have a two-stage macro-system in C++.
Obviously, a two-stage macro-system is not as capable as fully general macro system. However, it seems to me that we get the most bang for the buck from the first lift, and lifts above the first are not as common. Although, my use of Lisp-like macros is very limited—perhaps I'm just wrong?
Nice implementation, I like how the toplevel lifting is done. I was exploring similar things from a slightly different angle (using PEG natural extensibility): https://github.com/combinatorylogic/clike