moose icon indicating copy to clipboard operation
moose copied to clipboard

Limit use of TryFrom in kernel macros

Open mortendahl opened this issue 3 years ago • 0 comments

The use of TryFrom in the kernel macros can lead to confusion since it's a very general pattern that doesn't convey what's happening very clearly.

We are currently using TryFrom in two places in the macros:

  • in impl DispatchKernel in concrete_dispatch_kernel to convert from Value to specific type T
  • in impl DispatchKernel in symbolic_dispatch_kernel to convert from SymbolicValue to Symbolic<T>
  • in impl UnaryKernel/BinaryKernel/.. in (hybrid) kernel to convert from Symbolic<T> to either Symbolic<T> or T (via rust type inference)

Perhaps the first two are okay, but at least the latter should probably be given it's own trait or even just a fn on Symbolic returning eg an Option<T>

mortendahl avatar Sep 20 '21 14:09 mortendahl