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

Parameters with multiple types #654

Open
recvfrom opened this issue Nov 28, 2024 · 3 comments
Open

Parameters with multiple types #654

recvfrom opened this issue Nov 28, 2024 · 3 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@recvfrom
Copy link

What problem are you trying to solve?

It'd be helpful if the infra spec section on algorithm parameters mentioned how to have a parameter have two types (for instance, a type or failure, or a type and string). It seems like this is somewhat common

What solutions exist today?

It's possible to pass in two optional parameters and have the caller only set one of them, although it's less immediately clear that the two are mutually exclusive.

How would you solve it?

No response

Anything else?

No response

@recvfrom recvfrom added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Nov 28, 2024
@annevk
Copy link
Member

annevk commented Nov 28, 2024

Makes sense. Quick example in case you're actually stuck:

To post a result given a result or failure result:

("a result or failure" would be the type here and "result" in that type would link to "result"'s definition)

@recvfrom
Copy link
Author

recvfrom commented Nov 28, 2024

Makes sense. Quick example in case you're actually stuck:

To post a result given a result or failure result:

("a result or failure" would be the type here and "result" in that type would link to "result"'s definition)

Thank you! That makes sense. The other piece that would be helpful to document is what language to use to conditionally handle the different types passed. I guess for "<type> or failure" you could just do "if parameter is not failure", but if a parameter could be two types it's not clear to me how to distinguish the two cases (although I'm not currently stuck on this, so no need to reply urgently 😄 )

@annevk
Copy link
Member

annevk commented Nov 29, 2024

Usually we use "is" to do instance checks:

If a is a Blob object, then release the Kraken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants