Make macro syntax similar to function

IIRC this is based on Kohlbecker & Wand's POPL '87 paper:

https://dl.acm.org/doi/abs/10.1145/41625.41632

I do think it would be nice to have an "easy mode" syntax for simple function-like macros that just take expressions and produce expressions, especially for local (non-exported) helpers.

For example, I could imagine something like

macro fn divrem(a, b) => (a / b, a % b);

as a simple way to DRY some code locally, without needing to go through the effort of specifying argument and return types.

(That's not a great example, because I could just use num's method, but hopefully it gets the gist across.)

2 Likes