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

Clarify usage of bool return in stream-object-names::read #35

Open
itowlson opened this issue Nov 27, 2024 · 0 comments
Open

Clarify usage of bool return in stream-object-names::read #35

itowlson opened this issue Nov 27, 2024 · 0 comments

Comments

@itowlson
Copy link

From the stream-object-names WIT:

// This function returns the list of objects read, and a boolean indicating if the end of the stream was reached.
read-stream-object-names: func(len: u64) -> result<tuple<list<object-name>, bool>, error>;

I implemented two back-ends for this. In one of them, I interpreted this as "it indicates it by being false if the end of the stream was reached." In the other, I interpreted it as "it indicates it by being true if the end of the stream was reached." I didn't discover this until I got the second back end spun up and into testing.

Now, one clear lesson from this is "Ivan is an idiot." And that's fair. But idiots abound.

At minimum, the documentation should explicitly state the behaviour, e.g. "a boolean which is <value> if the end of the stream has been reached."

But much better would be to use an enum e.g. enum stream-status { at-end, moar } and return that. Or return a record with named fields. Bare booleans, even with docs, are just too error-prone.

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