Am Do., 24. März 2022 um 04:33 Uhr schrieb Nala Ginrut <
nalag...@gmail.com>:
> 1. We can't wrap every POSIX API since it's huge work.
> The reasonable way is to let users do the simple FFI for them.
> Of course, RnRS may want to define a core group of POSIX APIs in the standard, this is out of the topic here.
I think it is part of Committee's E work to define what POSIX
functionality and in which form will be offered to the user of the
large language.
> 2. There're many POSIX APIs that are simple without a C wrapper, errno is the only thing the runtime needs to take care of.
> The situation is similar outside POSIX, any libraries can share this convenience.
> If we provide simple FFI with errno, the RnRS can help users to save some work, rather than wrap too many things in C.
> This is meaningful work.
I understand; it would be a reasonable convenience procedure on top of
a more fundamental FFI. I don't see why it shouldn't make sense to add
it on top of a minimal FFI. Whether such a convenience procedure would
belong to F, B, or E could be determined later. For the majority of
the API defined by E, it would be just an implementation detail.
> However, I think it's still confusing for me about the cooperation between F and E.
> Are we going to establish a base-spec in F, and let E provide various interfaces according to the environment?
> It sounds like E will not provide a unified API for the different implementations, which is different from the general standard cases.
I think we have to distinguish between APIs and their implementations
here. On the level of APIs (for which SRFI 170 is one example), it is
up to Committee E to select which functionality to offer and in which
form. It will also be Committee E's work to suitably abstract over
POSIX/Windows/Android/... to increase portability. The only overlap
between Committee E and F in this regard would be in the area where
R6RS and R7RS already specify procedures accessing the environment. As
the set of procedures of this kind is rather small in R6RS and R7RS, I
don't see a big problem here. What may have to be agreed upon is the
general representation of filenames and strings coming from the
environment. In R6RS and R7RS they are usually modeled as Scheme
strings (that said, R6RS allows filenames of a more general type),
which is not a fully correct abstraction as OS filenames and strings
do not have to be valid Unicode strings and vice versa. A bytevector
interface or the specification of an abstract pathname type (see
C++17's std::filesystem::path for one attempt) that extends a suitable
subset of Scheme strings sounds like something that should be pondered
about by Committee E and F together.
As far as the implementation level is concerned, the current situation
(e.g. as in SRFI 170) is such that the concrete implementation is
outside of the standard. In the beginning, Committee E wouldn't need
to change this approach, I think. After a while, they will have a list
of what they would need from a standardized FFI to be able to
implement their APIs so far portably. Then, Committee F will have to
see whether it is reasonable to add an FFI with such capabilities into
the core. Using a standardized FFI will likely not squeeze out maximal
performance (because of a lot of compromises that will have to be made
to accommodate many different types of Scheme implementation
techniques), but being able to ship portable implementations of the
standard libraries would be a great boon.
Just my thoughts from my understanding, of course.
Marc