Skip to content

Change semantics of advance! to avoid changing the cursor.#9

Merged
jemc merged 1 commit intomainfrom
change/advance-semantics
Apr 22, 2022
Merged

Change semantics of advance! to avoid changing the cursor.#9
jemc merged 1 commit intomainfrom
change/advance-semantics

Conversation

@jemc
Copy link
Copy Markdown
Contributor

@jemc jemc commented Apr 22, 2022

The original semantics (leaving the cursor pointing to the end
of the stream after raising an error) weren't that useful in practice.
It's much more useful to leave the cursor unchanged in the case
that advance! fails to have enough bytes_ahead to move forward
by the requested amount, and raises an error!.

This is a breaking change in the semantics of an existing method,
but existing code using this method is not relying on those semantics,
so in practice it should not break existing code in known libraries.

The original semantics (leaving the cursor pointing to the end
of the stream after raising an error) weren't that useful in practice.
It's much more useful to leave the cursor unchanged in the case
that `advance!` fails to have enough `bytes_ahead` to move forward
by the requested amount, and raises an `error!`.

This is a breaking change in the semantics of an existing method,
but existing code using this method is not relying on those semantics,
so in practice it should not break existing code in known libraries.
@jemc jemc self-assigned this Apr 22, 2022
@jemc jemc merged commit 699786d into main Apr 22, 2022
@jemc jemc deleted the change/advance-semantics branch April 22, 2022 22:35
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

Successfully merging this pull request may close these issues.

1 participant