Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trait polymorphism in blob terms #23

Open
matko opened this issue Jan 27, 2022 · 0 comments
Open

Trait polymorphism in blob terms #23

matko opened this issue Jan 27, 2022 · 0 comments

Comments

@matko
Copy link
Collaborator

matko commented Jan 27, 2022

Multiple blob types may support the same type of operation. For example, a matrix, and a window over a matrix, will both support operations like getting the width, height, row retrieval, column retrieval, etc

The normal rust thing is to have a trait which defines contracts for these operations, which both types then implement. However, since we cannot retrieve trait types directly, any foreign predicate that serves multiple blob types still has to have a big check block to see what sort of blob it is dealing with and dispatch accordingly.

It would be good if we had some way to retrieve an object from a term which is able to do this dispatch for us. Directly retrieving a dyn T would be ideal, but this may be too tricky to get right.

Maybe there could be another macro like dispatch_arc_blob!(DispatchType, TraitType, [ConcreteType1, ConcreteType2, ConcreteType2]) which generates an enum type DispatchType with cases for all given concrete types (that all implement TraitType), and provides an implementation of TraitType that dispatches to the inner object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant