You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sig = Base.unwrap_unionall(sig) # not really handling most UnionAll,
32
+
opT, argTs = Iterators.peel(sig.parameters)
33
+
all(any(acceptT<:argTfor acceptT in ACCEPT_TYPES) for argT in argTs) ||return
34
+
@evalquote
35
+
# ...
36
+
end
37
+
end
38
+
39
+
on_new_rule(frule, define_overload)
40
+
```
15
41
16
-
`refresh_rules`(@ref) is used to manually trigger the hook function on any new rules.
42
+
The generation of overloaded code is the responsibility of the AD implementor.
43
+
Packages like [ExprTools.jl](https://github.com/invenia/ExprTools.jl) can be helpful for this.
44
+
Its generally fairly simple, though can become complex if you need to handle complicated type-constraints.
45
+
Examples are shown below.
46
+
47
+
The hook is automatically triggered whenever a package is loaded.
48
+
It can also be triggers manually using `refresh_rules`(@ref).
17
49
This is useful for example if new rules are define in the REPL, or if a package defining rules is modified.
18
50
(Revise.jl will not automatically trigger).
51
+
When the rules are refreshed (automatically or manually), the hooks are only triggered on new/modified rules; not ones that have already had the hooks triggered on.
19
52
20
53
`clear_new_rule_hooks!`(@ref) clears all registered hooks.
21
54
It is useful to undo [`on_new_rule`] hook registration if you are iteratively developing your overload generation function.
0 commit comments