Save expressions to .jl?
I would like to just do save(filename, ::Expr) with ModelingToolkit.jl generated code. Would it be right to add this as a standard FileIO.jl thing?
This may already work if filename ends in .jld or .jld2 (I haven't tested recently). Or are you thinking of a dedicated serialization format?
EDIT: Oh, from the title you mean as a loadable .jl file? That's easy if you just wrap in an eval but I'd guess you want it to have a readable & editable result? That would be interesting. I assume you know about https://docs.julialang.org/en/latest/devdocs/ast/ and would only be interested in the surface syntax?
Yeah, I am thinking it would be a nice helper to allow for just saving expressions to files, just doing write("function.jl", string(func)). It's nothing big but something that felt missing.
It would be excellent to make that easy. I've wanted something like that for a while.
If you've not done this before, I just submitted a PR myself (#254) so there are "fresh" models available. I guess this is a case, though, where you'd want save but not load support. We also couldn't have magic bytes, it will have to be detected entirely by the ".jl" file extension. So really it's not very similar to my recent PRs.
load could take a Julia file and make an array of Expr from it. 99.99% of the time you'd want include though.
Very dim memories clamoring for attention: https://github.com/timholy/MacroExpandJL.jl. Steal anything you find useful.
@ChrisRackauckas Do you still want this?