You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're talking about this situation, as seen in #214:
quasi {
{{{it}}} = {{{it}}} * 2;
}
The same comment in that issue also coins the Single Evaluation Rule: if a quasi unquotes the same AST fragment more than once, it's more likely than not to be a thinko.
(Why? Because in the end, it seems to be a blind spot for macro authors — at least for me — that it above might involve a side effect, and by duplicating it we're also duplicating the side effect.)
We can trivially detect this; at least we can trivially detect when the same variable is unquoted more than once in a quasi — which is probably good enough. If we can then make the error message nice and friendly, this ought to be a win. Maybe the error message should mention the is lazy@succinct trait, which allows a developer to keep not caring about duplicated side effects.
The text was updated successfully, but these errors were encountered:
There also needs to be a way to suppress the error message — simply because language designers are not omniscient, and might overlook a genuine need by a macro author.
At worst, I could imagine suppressing the error message through a macro trait. Maybe there's some nicer way.
We're talking about this situation, as seen in #214:
The same comment in that issue also coins the Single Evaluation Rule: if a quasi unquotes the same AST fragment more than once, it's more likely than not to be a thinko.
(Why? Because in the end, it seems to be a blind spot for macro authors — at least for me — that
it
above might involve a side effect, and by duplicating it we're also duplicating the side effect.)We can trivially detect this; at least we can trivially detect when the same variable is unquoted more than once in a quasi — which is probably good enough. If we can then make the error message nice and friendly, this ought to be a win. Maybe the error message should mention the
is lazy
@succinct
trait, which allows a developer to keep not caring about duplicated side effects.The text was updated successfully, but these errors were encountered: