Magma: Extending C with macros
github.com
github.com
#define with_open_file(fp, path, mode) \
for (FILE *fp = fopen(path, mode) ; fp ; fclose(fp), fp = 0) with_open_file(...) {
...
seek(fp,...)
read...
...
}
// nothing remains.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.
NULL (and 0) evaluate to false in C.
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?