The package is intended to enable redefining structs within Revise.jl based workflow. It exports the macro
@strev which (temporarily) wraps your struct like this
@strev struct S0
S0 = StrucRev_S0.S0
If you edit
S0, you will get a warning like
WARNING: replacing module StrucRev_S0
the S0 variable in your module will be re-bound to this new
StrucRev_S0, and you can continue to code.
In case you want to define outer constructor methods, the usage is like following
S0(x::Real) = S0(Int(round(x))
If your struct definition contains references to some external variables, they will be imported into the struct-wrapping module.
Another usage is
@strev const c = 1
which will rewrite it to
c::typeof(1) = 1
thus enabling you to experiment with the value of
c (but not with its type).
After you are finalized your types & constants, you simply remove all occurences of
@strev (and, well, re-start
For more usage examples see runtests.jl
The package is not registered yet, and can be installed from GitHub. I haven’t yer done any really thorough test with it.
I still have some “imposter syndrome doubts” - first, if it is that simple, why nobody implemented it yet (or maybe it is already done), and, second, I am definitely not good at macroprogramming and maybe very naive and made some terrible mistakes. If that is not the case and the package is of some value, I plan to add some documentation, more testing, CI, and then register it.
Thanks are due to @disberd for advice and a piece of code.
P.S. Sure there exist packages for the same purpose, which somehow escaped my attention till now - see discussion here