20146, "lydia-duncan", "IO module: how should we adjust openfp?", "2022-07-01T20:00:39Z"
It has the signature:
proc openfp(fp: _file, hints: iohints = IOHINT_NONE): file throws
And creates a file
that points to the C file pointer provided by the fp
argument.
Note that _file
is a primitive type inserted into the program by the compiler, and represents the C type FILE *
. It seems like it would be more appropriate for this type to be an extern type defined in CTypes, if that's something we can do. It probably should also be named c_FILE
or C_FILE
or c_file
in that case.
We think it would be reasonable to keep this function. If _file
does get moved to CTypes, should this function also be moved there?
It also seems like this function should be renamed. Similarly to the options proposed by #20143, here are some ideas we came up with:
- openFP
- openFp
- openFilePtr
- openFilePointer
- make it a factory function on the
file
type, e.g.file.fromFP
orfile.fromFilePtr
, since it's already open as a result of how it is obtained? - make it an initializer on the
file
type, for a similar reason?
This function throws a subset of the errors thrown by open
(as discussed in #20139). Similar updates should be performed to its documentation.