Postfix Macros and Let Place
a day ago
- #rust
- #macros
- #language-design
- Postfix macros allow syntax like `something.macro!(x, y, z)` but have stalled due to design issues.
- The 'no-backtracking rule' prevents macros from causing re-evaluation of expressions, complicating postfix macro design.
- Partial place evaluation is proposed to pre-evaluate temporaries while passing the remaining expression to the macro.
- `let place` is introduced as a way to alias places without causing place-to-value coercion, aiding in postfix macro implementation.
- Autoderef complicates `let place` due to the need to infer whether to use `deref` or `deref_mut` based on usage.
- `let place` is simple in MIR as it doesn't require new operational semantics and can be handled with existing MIR constructs.
- The feature is seen as elegant and potentially useful beyond postfix macros, though it introduces some surprising behaviors.
- Feedback is sought on the proposal, especially regarding mutability inference for autoderef.