# Designing a Paths Julep

**URL:** <https://discourse.julialang.org/t/designing-a-paths-julep/124335>\
**Category:** Internals & Design\
**Tags:** proposal, filesystem, path, rfc\
**Created:** [January 1, 2025, 12:37pm UTC](https://discourse.julialang.org/t/designing-a-paths-julep/124335 "2025-01-01T12:37:25Z")\
**Posts on this page:** 1\
**Showing post:** 75

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [January 6, 2025, 9:47pm UTC](https://discourse.julialang.org/t/designing-a-paths-julep/124335/75 "2025-01-06T21:47:25Z")

</div>

> [@jar1](#):
>
> I had an idea, inspired by @ExpandingMan’s [decision](https://gitlab.com/ExpandingMan/FilePaths2.jl#why-disallow-relative-paths) in [FilePaths2.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/FilePaths2) to exclude relative paths.
> 
> The idea I like is having two types: `Path` which is always an absolute path and `PathSegment` which is an offset that can be concatenated to an `Path` or to a `PathSegment`, just like `Year` can be concatenated to a `Year` or to a `Date` .

Exactly this idea occured to me (except with `AbsolutePath` and `RelativePath` types), the issue I had is that I can’t see a way to have this and platform-secific types without multiple inheritence. To elaborate, the problem is that we then have:

| | `<: AbsoluteSystemPath` | `<: RelativeSystemPath` |
| --- | --- | --- |
| `<: PosixPath` | `AbsolutePosixPath` | `RelativePosixPath` |
| `<: WindowsPath` | `AbsoluteWindowsPath` | `RelativeWindowsPath` |

Perhaps one could put absolute/relative-ness in a boolean type parameter? That might work but seems a but awkward to me.

> **Example (untested) implementation**
>
> ```julia
> abstract type SystemPath{isabs} <: PlainPath end
> 
> const AbsolutePath <: SystemPath{true}
> const RelativePath <: SystemPath{false}
> 
> struct PosixPath{isabs} <: SystemPath{isabs}
> path::GenericPlainPath{PosixPath{isabs}}
> end
> 
> const AbsolutePosixPath = PosixPath{true}
> const RelativePosixPath = PosixPath{false}
> 
> struct WindowsPath{isabs} <: WindowsPath{isabs}
> path::GenericPlainPath{WindowsPath{isabs}}
> end
> 
> const AbsoluteWindowsPath = WindowsPath{true}
> const RelativeWindowsPath = WindowsPath{false}
> 
> ```

My main concern with this design is the amount of potentially unstable path code that would result from it (e.g. parsing a path).

---

_[View the full topic](https://discourse.julialang.org/t/designing-a-paths-julep/124335)._
