We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The @matchast docs say there is no need to quote patterns so I tried that but I got an error. Using @match and quoting works.
@matchast
@match
using MLStyle using MLStyle.Modules.AST @active BinaryFloat(x) begin sign(x), significand(x), exponent(x) end @match 3.4 begin BinaryFloat(s,m,e) => (;s,m,e) end struct Floating end @active BinaryFloatF(x) begin sign(x), significand(x)-1, exponent(x) end function MLStyle.pattern_uncall(::Type{Floating}, to_pattern, _, _, arguments) @match only(arguments) begin :($s*(1+$f)*2^$e) => to_pattern(:(BinaryFloatF($s,$f,$e))) :($s*$m*2^$e) => to_pattern(:(BinaryFloat($s,$m,$e))) end end @match 3.4 begin Floating(s*m*2^e) => (;s,m,e) end @match 3.4 begin Floating(s*(1+f)*2^e) => (;s,f,e) end function MLStyle.pattern_uncall(::Type{Floating}, to_pattern, _, _, arguments) @matchast only(arguments) begin $s*(1+$f)*2^$e => to_pattern(:(BinaryFloatF($s,$f,$e))) $s*$m*2^$e => to_pattern(:(BinaryFloat($s,$m,$e))) end end # SyntaxError("Malformed ast template, the second arg should be a block with a series of pairs(`a => b`),
MLStyle v0.4.17 Julia 1.9.0-beta3
The text was updated successfully, but these errors were encountered:
Thanks for your informative issue.
You might change @matchast only(arguments) begin to @matchast only(arguments) quote.
@matchast only(arguments) begin
@matchast only(arguments) quote
function MLStyle.pattern_uncall(::Type{Floating}, to_pattern, _, _, arguments) @matchast only(arguments) quote $s*(1+$f)*2^$e => to_pattern(:(BinaryFloatF($s,$f,$e))) $s*$m*2^$e => to_pattern(:(BinaryFloat($s,$m,$e))) end end
The error message should be improved and I'm to figure out why we decided to use quote instead of begin here.
quote
begin
Sorry, something went wrong.
I see, it is documented that way, I just didn't notice. Thanks.
No branches or pull requests
The
@matchast
docs say there is no need to quote patterns so I tried that but I got an error. Using@match
and quoting works.MLStyle v0.4.17
Julia 1.9.0-beta3
The text was updated successfully, but these errors were encountered: