hiroshinishio / julia

The Julia Programming Language
https://julialang.org/
MIT License
0 stars 0 forks source link

Generalize joinpath to take the OS as an argument #20

Open vtjnash opened 2 weeks ago

vtjnash commented 2 weeks ago

I'd love if we merged the lines https://github.com/JuliaLang/julia/blob/6f3fdf7b36250fb95f512a2b927ad2518c07d2b5/base/path.jl#L257-L325 which currently contain two different joinpath functions based on your OS, into a single function which gets an os-keyword. Concept idea:

function joinpath(parts; os=Sys.KERNEL)
  if Sys.iswindows(os)
    #windows variant of joinpath
  else
    #other variant of joinpath
  end
end

joinpath(parts...; os=Sys.KERNEL) = joinpath(parts; os)

Many of the other functions (such as splitdir and the path regexes) may need to be similarly generalized to allow the user to call both the Windows and Unix variants of those

From https://github.com/JuliaLang/julia/issues/55648

gitauto-ai[bot] commented 2 weeks ago

Click the checkbox below to generate a PR!

@vtjnash, You have 5 requests left in this cycle which refreshes on 2024-09-04 02:56:25+00:00. If you have any questions or concerns, please contact us at info@gitauto.ai.

gitauto-ai[bot] commented 2 weeks ago

Sorry, we have an error. Please try again.

Have feedback or need help? Feel free to email info@gitauto.ai.

rapus95 commented 2 weeks ago

Many of the other functions (such as splitdir and the path regexes) may need to be similarly generalized to allow the user to call both the Windows and Unix variants of those

@vtjnash I wonder if it makes sense to create modules for the OS and group all the functions according to OS and then only create a new layer of functions which redirects into the right OS module (which holds different FUNCTION objects than the outer redirectors). That way each call would use compatible splitdir, regexes etc since the OS arg just decides on the entry point for the machinery.

vtjnash commented 1 week ago

That is possible, and I was considering that too, though dispatch is more common. With this, I was hoping to discover what sort of implementation gitauto would come up with, and how close it would come to the proposed design. It seems there was an unexplained failure though?

gitauto-ai[bot] commented 3 days ago

Sorry, we have an error. Please try again.

Have feedback or need help? Feel free to email info@gitauto.ai.