Closed MilesCranmer closed 1 year ago
Also, @ChrisRackauckas, I would be interested in hearing what you think of this approach as well.
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
src/OperatorEnumConstruction.jl | 53 | 65 | 81.54% | ||
<!-- | Total: | 53 | 65 | 81.54% | --> |
Totals | |
---|---|
Change from base Build 3340998351: | -0.7% |
Covered Lines: | 915 |
Relevant Lines: | 1001 |
Will merge this relatively soon so let me know any other comments. I think while this macro isn't ideal, it's much safer than the current strategy of Base.MainInclude.eval
, so should be preferred. We can always improve the macro later; I think the syntax won't need to be changed.
Going to merge now because I think the current approach of Base.MainInclude.eval
is a bit dangerous and I'd like to fix it. However I'm very open to changing this PR's approach in the future - it is by no means final.
This PR makes it safer to extend user-defined operators. Now, you can extend operators like so:
This macro will take into account what module called the macro, and define it in the same scope. Thus, it will be much safer than the current method which is a bit of a hack. This new approach is a single macro which spits out a bunch of functions like so:
(assuming that
+
is the first operator).The downside is that the macro is very complex.
It works for functions defined in modules too:
Then, we can use functions as follows:
@odow if you have time, I would be eager to hear your thoughts on this!