Skip to content

Semantics of seek #57618

Open
Open
@jakobnissen

Description

@jakobnissen

I'm not sure what the precise semantics of seek should be. Currently, it's underdefined, and I think we should exploit that the current lack of documentation (and inconsistent behaviour) gives us freedom to define seek as we want (rather than just documenting how it actually behaves currently).

  • Is the position always an integer, or can an IO define a custom indexing type e.g. to carry state?
  • Should it be documented that the position must be zero-indexed?
  • What should the behaviour be when seeking to a negative offset? This errors for IOStream, but not for IOBuffer
  • What should the behaviour be when seeking to something larger than the filesize? Currently, it seeks to the end, but @vtjnash in Refactor IOBuffer code #57570 suggested it should instead behave like lseek.
  • What should happen when calling seek on an unseekable IO? Should it be a noop or throw an error? Which error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ioInvolving the I/O subsystem: libuv, read, write, etc.needs decisionA decision on this change is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions