On Fri, Feb 7, 2020 at 5:19 PM Lassi Kortela <xxxxxx@lassi.io> wrote:

* Record-like abstract data type (MIT Scheme/Kawa/Racket/Common Lisp)
* Strings (most other Schemes and Python, Go, etc.)

I will use the term "standard procedures" for the various procedures in the Scheme standards that accept pathnames.  The implementations in your first list support both strings and ADTs on equal terms: you can pass either to the standard procedures.

As for Python, it really belongs on your first list: the ADT in question is exported by the pathlib standard library.  However, it is only since version 3.6 that the standard procedures accepted ADTs directly. What my pre-SRFI proposes is like how Python worked before 3.6: that is, a library that allows you to create and manipulate path objects, but requires you to convert from the object to a string before transmitting it to a standard Scheme procedure.  This can be made portable as the "equal terms" approach cannot.  What is more, it has the same data model as Python's pathlib: a drive, a root, a sequence of names.

Until my last draft the path object was a record, but then I saw that it might just as well be a list of strings, which would make it easier to manipulate with Scheme's standard list and string operations.  List of strings or record, however, it is still a path object.  So a conformant implementation of the pre-SRFI would not require, but would permit, such objects to be passed to standard procedures.  Portable programs would have to use `pathname` to convert the path object into a pathname.

In any case, once you have such a library you can operate internally constructing paths however you like, and you don't have to care what Posix's idea of the cwd is.  I wrote a non-anonymous FTP server once that would lock the client to a particular directory after logging in, and because it did its own resolution of the pathnames received from the client, it was guaranteed safe with no need for chroot or such like tricks.



John Cowan          http://vrici.lojban.org/~cowan        xxxxxx@ccil.org
They tried to pierce your heart with a Morgul-knife that remains in
the wound.  If they had succeeded, you would become a wraith under the
domination of the Dark Lord.         --Gandalf