Hi all, some of us are working on an interface for reinforcement learning https://github.com/JuliaReinforcementLearning/CommonRLInterface.jl. There will be many interface functions that are optional, and perhaps multiple ways to accomplish similar things. In order to make it easier for algorithm-writers to tell what functions an environment supports, I created a function called provided
that acts similar to a trait for every optional function in the interface. It has the exact same usage as Base.applicable
, but it is inferrable. I provide a @provide
macro that can be used, for example, as follows
@provide CommonRLInterface.clone(env::MyCommonEnv) = deepcopy(env)
to automatically define the trait when the method is written.
If applicable
were inferrable, we could just use that instead. If this was a good design pattern, it seems like applicable
would be inferrable and could replace or be used in IteratorEltype()
in Base. Since it is not used in Base and applicable
has not been made inferrable, I am suspicious that there is some problem with the pattern. Am I missing something? Is this a good pattern? Why wasn’t applicable
used in the AbstractArray
traits? (I guess I still don’t understand why applicable
is not inferrable it seems like it should be easy to put the backedges in, but has not been done even though it was desired in 2017 https://github.com/mauro3/SimpleTraits.jl/issues/40)