Skip to content

Comment on Quote-unquote "macros"

Comments

Rust macros are sort of sufficient to do the kind of rewriting mentioned, but it's maybe cheating because you have to annotate the function with the macro which allows the macro to mangle the whole function body.

yeah, i don't think that's valid because it turns a local transformation into a global transformation (sort of local, but only to the entire top-level function, which can be arbitrarily large)

if you're willing to do the global transformation yourself instead of enlisting the computer to do it for you, you don't even need macros at all; you can do that with henry's example:

    const resultMap = new Map();
above the function
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.