I rewrote the `memoize` crate using macro_rules using nightly features

Currently only supports basic usage, not full usage with lru and config.

I saw the new macro_attr attribute and wanted to try it out (alongside macro_metavar_expr_concat), so I found a proc_macro crate that seemed simple enough and rewrote it based on its documentation.

I hope this serves as a good proof-of-concept of what will hopefully be possible in stable rust in the future, and potentially inspire other people to mess around with macro_rules!.

2 Likes

Can you explain this ? How does it work?

It works like memoize, except defined using macro_rules!. see that crate's docs for info, and see the tests/ directory for usage examples for memoize-decl.

1 Like

memoize is using #[proc_macro_attribute] It even more complex. :frowning: . Sr. Can you tell me the principal behind your macro ?

the original crate is more complex because it supports additional configuration.

the idea of the macro is that it caches the output of a pure function so repeated calls don't require recomputation.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.