Skip to content

2019 001 Correction to PRIM_IO

John Reppy edited this page Jun 4, 2019 · 1 revision

Proposal 2019-001

Correction to the PRIM_IO signature

Author: John Reppy
Last revised: June 4, 2019
Status: proposed
Discussion: issue #26


Synopsis

The PRIM_IO signature, which is the result signature of the optional PrimIO functor, has the wrong type specified for theavail field of the reader datatype.

Description

The current Basis Library specification gives the type as

  avail : unit -> int option

For readers that represent input files, the OS.FileSys.fileSize function provides the natural implementation of avail, but it returns the file size as a Position.int value. Since int and Position.int may be different types, the correct type for avail should be

  avail : unit -> Position.int option

Impact

Some code may break, but the most common use of this API is likely to be in the Basis Library code provided by SML implementations. In those cases where Position.int and int are the same type, there should be no problem.

Rationale

This proposal fixes a clear mistake in the original Basis Library specification. Without this change, it is not possible to support the expected semantics of avail (i.e., it returns the file size minus the current position) for large files when the default int type is 32-bits or smaller.


History

  • [2019-06-04] Proposed