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
Suppose I am trying to write an ast transformation.
using MacroTools: postwalk
postwalk(expr) do e
r =@trymatch e begin
:($f($x)) =>Some(x)
:($g($x)) =>Some(x)
end@match r beginnothing=> e
Some(x) => x
endend
Note Some(x) is necessary because otherwise it is impossible to distinguish between "the value happened to be nothing" and "matching failed". It would be a little nicer if @trymatch did the Some(x) automatically because (1) it is convenient for users who use Some anyway and (2) it will lead users toward correct usage; currently it is too easy to accidentally forget Some which may lose information.
The text was updated successfully, but these errors were encountered:
Suppose I am trying to write an ast transformation.
Note
Some(x)
is necessary because otherwise it is impossible to distinguish between "the value happened to benothing
" and "matching failed". It would be a little nicer if@trymatch
did theSome(x)
automatically because (1) it is convenient for users who useSome
anyway and (2) it will lead users toward correct usage; currently it is too easy to accidentally forgetSome
which may lose information.The text was updated successfully, but these errors were encountered: