tustvold commented on issue #3999: URL: https://github.com/apache/arrow-rs/issues/3999#issuecomment-1493416606
> Having a kernel like add(array: &dyn Array, scalar: &Scalar) is certainly compelling The eventual idea would be to not have such a kernel at all, instead you would just call `array.add(scalar)` and let trait-resolution work out what variant to call based on the types you give it. > One thing I think would be a step back was if the traits were complicated enough to express things like can't add PrimitiveType to TimestampType -- because I think that would generate very hard to understand compiler error messages. I think the errors are fairly clear? - https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e5e12eacb2b9041f988afe2012637a74 > why use a trait for Scalar rather than an enum Mainly for consistency with the use of `dyn Array`. We need a strongly typed `PrimitiveScalar` or similar, but whether you wrap that up in a trait object or an enum for the dyn dispatch is largely immaterial, you will end up a large match block either way. > Do we plan to remove all typed kernels The intention is for the traits to be implemented for the concrete types, filling the role of the "typed kernels", whilst also being implemented for the trait objects filling the role of the "dyn kernels". The trait-dispatch machinery in Rust will automatically work out which one is appropriate to call. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
