Skip to content
New issue

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

Improve style in Base/experimental.jl [NFC] #51965

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base/experimental.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ code to resort to runtime dispatch instead.
Supported values are `1`, `2`, `3`, `4`, and `default` (currently equivalent to `3`).
"""
macro max_methods(n::Int)
0 < n < 5 || error("We must have that `1 <= max_methods <= 4`, but `max_methods = $n`.")
1 <= n <= 4 || error("We must have that `1 <= max_methods <= 4`, but `max_methods = $n`.")
return Expr(:meta, :max_methods, n)
end

Expand All @@ -156,13 +156,13 @@ for max_methods. This setting is global for the entire generic function (or more
the MethodTable).
"""
macro max_methods(n::Int, fdef::Expr)
0 < n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.")
1 <= n <= 255 || error("We must have that `1 <= max_methods <= 255`, but `max_methods = $n`.")
(fdef.head === :function && length(fdef.args) == 1) || error("Second argument must be a function forward declaration")
return :(typeof($(esc(fdef))).name.max_methods = $(UInt8(n)))
end

"""
Experimental.@compiler_options optimize={0,1,2,3} compile={yes,no,all,min} infer={yes,no} max_methods={default,1,2,3,...}
Experimental.@compiler_options optimize={0,1,2,3} compile={yes,no,all,min} infer={yes,no} max_methods={default,1,2,3,4}

Set compiler options for code in the enclosing module. Options correspond directly to
command-line options with the same name, where applicable. The following options
Expand Down Expand Up @@ -195,7 +195,7 @@ macro compiler_options(args...)
elseif ex.args[1] === :max_methods
a = ex.args[2]
a = a === :default ? 3 :
a isa Int ? ((0 < a < 5) ? a : error("We must have that `1 <= max_methods <= 4`, but `max_methods = $a`.")) :
a isa Int ? ((1 <= a <= 4) ? a : error("We must have that `1 <= max_methods <= 4`, but `max_methods = $a`.")) :
error("invalid argument to \"max_methods\" option")
push!(opts.args, Expr(:meta, :max_methods, a))
else
Expand Down