Open Seelengrab opened 1 year ago
Come to think of it, the argument checking out so allow raw symbols as well :thinking: So this additional version would be needed too:
macro constfield(ex::Symbol)
ex = esc(ex)
if VERSION < v"1.8"
ex
else
Expr(:const, ex)
end
end
I wonder if this could be handled with Compat.@compat
whenever it wraps a struct?
I wonder if this could be handled with
Compat.@compat
whenever it wraps a struct?
That would be nice, but doesn't work because const
fields don't even parse:
julia> :(mutable struct Foo
const bar
end)
ERROR: syntax: expected assignment after "const"
(That's julia v1.6.) So there's no way of getting them into the argument of @compat
.
Yeah, that's why I ultimately ended up with the @const
-per-field macro that's a no-op on <1.8.
Hi!
I have this in one of my packages:
and wanted to ask whether there's interest to have this macro in Compat? It's used like this:
The idea is to have a noop (if unsupported) replacement for
const foo::Int
in struct definitions.