On Thursday, 4 November 2021 18:58:57 PDT Andrey Semashev via Std-Discussion
wrote:
> That's not a rationale, it's a consequence of the specification. I'm
> interested in the motivation for the specification being written this
> way (if it was written so intentionally, with respect to the case I
> described).
It seems that operator/ is implemented like the "cd" command, not a string
concatenation.
Think of this:
$ cd /usr
$ cd /bin
$ pwd
/bin
You don't expect it to show /usr/bin (whether /bin is a symlink to /usr/bin or
not is irrelevant here).
I agree with you it's surprising at first sight because
"//net/foo" + "/bar"
makes it a subdir of //net/foo.
But it's not meant to be like string concatenation.
The only prior art of operator/ that I know of is in the Meson buildsystem and
it behaves exactly like fs::path. See
https://mesonbuild.com/Syntax.html#string-path-building
>>> Path('//net/foo') / Path('/bar')
PosixPath('/bar')
and on Windows,
>>> Path('//net/foo') / Path('/bar')
WindowsPath('//net/foo/bar')