3 ms·
it's a workaround for a lacking type system
by selckin 5y ago
it's a workaround for a lacking type system
- atq2119 5y agoNot really. It'd be more accurate to say it's a workaround for an existing proper hygienic macro system built on static introspection and code generation.
- jstimpfle 5y agoNot really. It's not a workaround - it just works. Maybe most uses of lexical macros could be done with hygienic macros / macro replacement bodies that are fully formed expressions (AST nodes), but not all of them. For those macros, really the "hygienic" doesn't matter half as much as people pretend. Don't do complex macros where the "hygienic" is required. Don't generate code, write code. If you need to generate syntax to remove boilerplate, then sprinkle a few macros in. But to generate syntax, in general you'll need a lexical macro system.
- orwin 5y agoI'd say its not really a workaround, its a feature. And a hard one to use well. But as someone said in another comment, i think reading the preprocessor in C and especially C++ with the templating is really interesting and help a lot understand how the OG team behind the code used to work. Some tricks are "too clever" for me originally, but with proper documentation on these tricks, i understand tehm and sometime, i have a sudden hindsight/sudden clarity (i don't know how to say it, its a bit like entering the zone?)
- jhgb 5y agoSounds like that it's more a workaround for lacking a proper macro system.
- jstimpfle 5y agoHow is a straightforward solution to some development problem (create multiple language entities, like enum + data tables, from a single point of definition in the source code) a workaround for some lacking thing? Maybe you could clarify by posting a better version of what GGP suggested.