How to implement a method with a generic return value? #623
Unanswered
yuan-y-chang
asked this question in
Q&A
Replies: 1 comment
-
|
I think the compromise solution is using a type ID and wrap with a generic method to infer the type ID. ( interface Getter {
# Get a value by its type ID
get @0 [T] (typeId: UInt64) -> (value :T);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The official example says
But how to implement this on the server side?
My schema is
...and the codegen is
Can I specify/test the
Tin the server?I have also tried the polymorphism solution, where generialize the
Getterinterface.But
Getter(Foo)andGetter(Bar)have the same ID, so I need to define the interface alias to specify them on the client side, which has a large amount of duplicate code....and the codegen causes duplicate IDs in a match block. (dispatcher type)
Beta Was this translation helpful? Give feedback.
All reactions