News for hackers. Stuff that matters.
Re:JavaScript Macros in Bun by Zambyte on Friday June 30, 2023 @02:56PM (#36540326)
It's cool to be able to compute things at compile time, but one thing that doesn't seem clear from this post is: can macros return code? If so, how? It seems like they can only return values that are computed at compile time, which severly limits what you can do with macros.
Re:JavaScript Macros in Bun by colinmcd on Friday June 30, 2023 @03:08PM (#36540528)
This is mentioned under "Limitations"

> The result of the macro must be serializable!

> Functions and instances of most classes (except those mentioned above) are not serializable.

Re:JavaScript Macros in Bun by Zambyte on Friday June 30, 2023 @03:52PM (#36541197)
Well those are both slightly different than "code". I mean something more like returning an S-expression, or a JS AST object, and having that be inlined. That should have no problem with serialization, since it could just be dropped into the AST (unlike a function or class).