All of mathematics is built by extending a concept beyond where it is intrinsically defined. If you start with counting numbers 1, 2, 3, 4… , you can define addition, and then define subtraction as “find the number which, when added to X, gives Y”. At that point, you need to define negative numbers, which solve problems like “find the number which, when added to 5, gives 2”. Then you can define multiplication as repeated addition; but it doesn’t make sense to add together a negative number of things, so multiplication by negative numbers is defined in the most logical way.

It’s the same when we step outside of pure mathematics. We define that adding two strings is concatenating them. This violates some of the key principles of arithmetic (`x + y`

isn’t always the same as `y + x`

for example), and it becomes harder to define subtraction (although personally I think that `x - y`

is best defined as `x.replace(y, "")`

as that’s both sensible and useful). Similarly, we can define that `"spam" * 3`

is `"spamspamspam"`

, which, again, makes perfect sense; but what is `"spam" * 2.5`

? (Again, there IS a sensible and sometimes-useful definition, which is `"spamspamsp"`

, but at very least, it’s clear that this isn’t as simple as plain mathematics would imply.) What about `"spamspamspamspam" / 2`

? I would accept, as sensible answers, `"spamspam"`

but also `["spamspam", "spamspam"]`

, and actually, neither of those is as practially useful as `["sp", "am", "sp", "am", "sp", "am", "sp", "am", "sp", "am"]`

(splitting into two-character units), even though that one makes a lot less sense.

So, what is the absolute value of a number? Mathematically, it’s the distance from the origin to that number. Algebraically, that can be defined by Pythagoras; square each component in the number, and take the square root. (For real numbers, you can optimize this down to `-x if x < 0 else x`

but for complex numbers you need the full calculation.) So is an “absolute path” the same as the distance from the origin to that path? … Kinda. I mean, the root directory is kinda the origin, and you could say that the most direct path to a node is its “distance”. But once again, we’re really stretching things.

So in terms of logic and sensibility, this could really go either way. It’s not VERY logical, but it is at least a little bit logical. Which leaves us with the third criterion: Practicality. How useful is this? Is it convenient to be able to say `path / "filename"`

? You bet it is!! It reads well, and does a very common job. But is it useful to write `abs(path)`

? Ehhhhhh… not so much. Maybe? Maybe if you’re doing a huge number of path manipulations and need to absolutify them all? But it’s not really all that big a deal for most programs.

(Side note: If it weren’t for the fact that paths are traditionally separated by slashes, and division is also traditionally written with a slash, there’d be no value in making `path / "fn"`

work. Instead, it would be much better written as `path + "fn"`

as it’s much more closely related to string concatenation. I don’t think that affects decisions about `abs`

but it’s worth keeping in mind; for example, multiplying paths wouldn’t really be the inverse of dividing them, since dividing is really concatenating.)