On Thu, Apr 30, 2020 at 09:12:15AM +0300, Lassi Kortela wrote:
> > (current-directory [new-directory]) → string (procedure)
> > POSIX getcwd(), chdir()
> >
> > An R7RS or SRFI 39 parameter representing the current (working)
> > directory. If it is invoked with no arguments, it returns the current
> > directory as a string. If called with a single string argument, it sets
> > the current directory to the new value. If referenced by a parameterize
> > expression, the current directory is set to the new value, and (unless
> > the operating system prevents it) restored at the end of parameterize.
> > the user's home directory.
> >
> > Note that in POSIX the working directory is per-process rather than
> > per-thread. However, a Scheme implementation which natively provides a
> > per-thread working directory should also provide per-thread semantics
> > for this procedure.
>
> We should probably change that to "MUST provide per-thread semantics". If
> that's optional, won't it hamper the portability of multi-threaded Scheme
> programs if they can't trust how the current directory is handled? In fact,
> if some multi-threaded Schemes have a per-thread WD and others don't, how
> will people write portable thread code changing the current directory?
I think there are two problems mixed here, and there are conflicting.
- (1) providing a portable `current-directory' function to Scheme users
- (2) exposing the POSIX API in a portable way to Scheme users
For (1), as soon there is agreement, it could be per-thread or per-process. I am
unsure about makes it implementation dependent. I would say that it depends how
parameter are managed by the implementation (per thread or per process). Else,
you could have, for example, a "standard" parameter per-process, and this
particular parameter required to be per-thread, and it is inconsitent.
Per srfi-39, a parameter seems to already being implementation dependent.
Given that there are semantic differences in the presence of threads and
that there are valid reasons for choosing each semantics, this SRFI does
not specify the semantics of parameter objects in the presence of
threads. It is left to the implementation and other SRFIs which extend
this SRFI to specify the interaction between parameter objects and
threads.
For (2), the "current working directory" definition is per-process.
Thanks.
--
Sebastien Marie