Questions tagged [macro]
Use this tag for questions about design or implementation of language preprocessor macros that are able to perform limited rewriting of source code before evaluation. Do not use for questions about editor macros or design of automation languages.
6 questions
1
vote
0
answers
163
views
How to implement a formatter for a templating/macro language that can be run over a wide range of different languages?
I'm considering writing a formatter for Jinja2. Jinja is a template language that can preprocess a wide variety of different languages, mostly HTML but it's also commonly used for XML, SVG, JSON, YAML,...
1
vote
1
answer
203
views
Implementing automatic derivation without macros?
In Rust:
#[derive(Display)]
struct Foo<T>(T);
If T conforms to the Display trait, ...
9
votes
1
answer
801
views
How does Rust parse ambiguous macros?
Rust's macros require them to be delimited by either parentheses, braces, or brackets, such as println!(arg) or foo! { bar, baz }...
31
votes
3
answers
13k
views
Why did Rust require macro names to have an exclamation point at the end?
Why did the designers of the Rust programming language require that macro names have to end with an exclamation point?
I observe that both Common Lisp and Emacs Lisp language variants do not appear, ...
3
votes
2
answers
158
views
How can the pitfalls of preprocessor macros be mitigated/avoided?
A controversial topic among programming language designers is preprocessor macros such as #define directives in C. They can cause problems if used incorrectly.
<...
19
votes
6
answers
2k
views
How could a language with a C-style syntax implement homoiconicity?
A part of why Lisp's macros work so well is that the code is just a list of symbols, and it is therefore simple to manipulate using a regular Lisp function. How could a language that uses a syntax ...