2 ms·
The Rust example made me feel anxious. I never got macro systems. What's so hard to read about a basic multi dimensional array? It's like the most basic of data
by z3t4 7y ago
The Rust example made me feel anxious. I never got macro systems. What's so hard to read about a basic multi dimensional array? It's like the most basic of data structures. Am I the only one that can easily picture this in my head ?
- squiggleblaz 7y agoIsn't the advantage of the macro in the Rust example not the fact that it's a more convenient multi-dimensional array (is it even that? like you say...) but that we're using literals not for their literal value, but for some local symbolic value. For instance, `1` doesn't mean 1, it means whatever `KC_1` means (perhaps that 63). I surely find the Rust macro example easier to read in isolation. Macro systems that are effectively simple find-and-replace are terrible. Modern macro systems that give you access to the actual syntax tree to manipulate directly - well, I feel more comfortable writing a little more code than using them, but at some point the differences mount up. I suspect the tradeoff here is better in the demonstration than the actual use, but other cases are valuable.