Along the same lines, it occurred to me that with named tuples and getproperty
, one could have
@flexible struct Foo
x::Int
y::Float64
end
expand into
struct Foo{NT}
_vals::NamedTuple
end
Foo(x, y) = Foo((x=x, y=y))
getproperty(f::Foo) = ...
Then with Revise.jl one could change the fields of Foo
as much as you want without restarting and strip off the @flexible
once it’s “frozen”. It would have a few restrictions, but at least it would work in functions
f(::Foo, ...) = ...