I suppose all of these points have been made already somewhere in this thread, but just my 2 cents on the different issues:
- Path joining and string concatenation are entirely different things that should not use the same operator under any circumstances:
"root" * "folder"is"rootfolder", butPath("root") / "folder"isPath("root/folder"). - AFAIK, there is not a single language where the same infix operator is used for string concatenation and path joining. In fact, using
/is completely universal (possibly up to Haskell, but</>is close enough). I would consider it completely insane for Julia not to follow precedent here. If you really can’t stomach/being used both for division and path joining, make it separately importable, although that seems silly to me. Or come up with something that at least involves/, the way that Haskell does (a macro@/isn’t possible, right?). In any case, there would still bejoinpath(p"folder", p"subfolder", "file.ext")for anyone who doesn’t want to use an infix operator. - There is no such thing as string division (existing or planned) as an inverse to
*, so there is absolutely no confusion with/as an operator on Paths. Nobody in the world would ever be confused by this. - I don’t think
Path("root") * "folder"(i.e., the*operator forPathobjects) absolutely needs to be defined, but if it is defined, it should obviously be equivalent toPath("root" * "folder"). That is, it should implement concatenation, not joining. - It’s nice to have a string-macro
p"folder". I don’t know that that macro absolutely needs to support things like interpolation, but if it does,p"$root$directory$file"should be exactly the same thing asPath("$root$directory$file"). Under no circumstances is interpolation an alternative to path joining. I think all the semantics ofp"folder"are pretty clear if you remember it as a shorthand forPath("folder") - It would definitely be possible to have
p"folder" / ("filebase" * ".ext"). It might be okay to havep"folder" / "filebase" * ".ext"without parenthesis if*already has higher precedence than/, or if we want to allow*forPathandStringobjects. Of course,p"folder" / "$(filebase).ext"is always okay, with the caveat: - While combining path joining and string concatenation is obviously possible, for file extensions in particular, those should be part of the
PathAPI, and should be something likep:folder" / "filename" |> with_extension("ext")to change or add extensions. With a well-designedPathAPI, the actual need for string interpolation or concatenation should be extremely minimal. p"relative_path" / p"absolute_path"should not be an error, but simply returnp"absolute_path". This is what enablescwd / fileto save a file with an absolute or relative path insidecwd, without having to make manual distinctions. I would note that, e.g., Python’spathlibis very well-designed and has thought about details like that. It behooves us to learn from that design and the design of other proven solutions. I would strongly recommend followingpathlib’s design overall, with the obvious change that in Julia, we need to design around functions, not OOP class methods.