3 ms·
I disagree that Dart's code transformers are comparable to Macros- their intent is runtime optimization- take valid code which runs fine in the VM and optimize
by randomfool 11y ago
I disagree that Dart's code transformers are comparable to Macros- their intent is runtime optimization- take valid code which runs fine in the VM and optimize it for dart2js compilation.
This feels more like an advanced compilation feature than macros which are typically used to encapsulate a set of complex operations.
- skybrian 11y agoCode transformers are more general than macros and I focused on one way to use them. I disagree that they're an optimization in this example, since the original code isn't being transformed but rather overridden with a separate implementation. It's more like overriding a method in a subclass; the intent is probably for the implementations to have equivalent behaviors, but the details differ and there can be bugs. Just like when a method is overridden, the reader should be able to see that there are multiple implementations and understand how they work. If you want to understand performance, you need to look at the production implementation.