-
-
Notifications
You must be signed in to change notification settings - Fork 746
Add struct Path
to std.path
#1333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Well, thank for the work, but we already discussed this in the past and decided that it was not worth having an object to handle paths. std.path uses strings, and that works fine. However, for future notice, I would point out some implementation details that would be needed were we to merge your work into Phobos.
|
Where was this discussed? |
@alexrp, I started off with a struct with some method prototypes, and it became pretty easy to fill them in as much of it was just a basic wrapper around std.path. I suppose I should make a post on d.D, but it didn't occur to me to do that for a commit. |
@jmdavis, Can you point me to the discussion about why Path should not be an object? I can't really see how it'd hurt std.path with its addition, as it's only meant to be a high level wrapper around std.path functions, not depreciate them. |
I believe that it was this thread here: http://forum.dlang.org/post/4C91FF15.5070508@nifty.com Andrei in particular seemed against the idea. So, if you want something like this, I think that it's going to need to be discussed in the newsgroup first. Personally, given that we already have a whole module operating on paths as strings, I think that it would be a bad idea to add a struct to handle them. None of the rest of Phobos is going to handle them with that struct, so having it would go against how the rest of the library works and make it so that some code out there uses the string and some code uses the struct. I think that it's far cleaner for the std lib to just have the one way. 3rd party libraries are obviously free to do as they please, but as we already decided that std.path would operate on strings, I think that we should continue with that. |
@jmdavis Well, I'm glad that the community is discussing it. I've made another commit that deals with the code style issues you mentioned, however they won't show up in this commit as its been closed. |
std/path.d
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary to use this attribute style when there is only one affected symbol, and it's not like Path
is likely to have more fields in the future.
At any rate, it's not common D style, including in Phobos.
I know this might not get anywhere, but I decided to review it anyway. Not mentioned in line comments: this needs |
I think this was closed prematurely. He's taken it to the NewsGroup and is still dedicated to working on the implementation. Can we please not close pull requests unilaterally minutes after they were opened? |
Let us reopen this and see where the NG discussion and the improvement of this patch goes and then make a decision. |
There's no reason to leave a pull request open if it's clearly not acceptable, and it was my understanding that we had already decided against this. Given the discussion in the newsgroup, we can reopen it, but there will have to be a clear consensus on it among the Phobos devs (or at least Andrei needs to be convinced) before we consider pulling it. And I'm still very much against this idea. We already went with a string-based solution, and I think that it's a big mistake to have two solutions like this. |
Well, look at it like this: This is an improvement over the string-based solution. For good reasons, we can't remove all the string function because that would break endless amounts of code. Just because something was voted against in the past doesn't mean that it should never be considered again. Sometimes, in retrospect, something that seemed like a bad idea could actually be the good idea. |
cc @kyllingstad |
std/path.d
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these is*
functions should be @property
.
All functions here probably also need to be marked |
Looks like they should be |
Why not give it some time? What may be clear to one person is not so clear to someone else. At any rate, it wasn't clear to the requester, and you closed it without any conversation. If you had just pointed to the old discussions and summarized the consensus at the time without closing the pull request right away, the requester could have closed it if he, as a result, had become disinterested in pursuing it. When a contributor with commit access closes a pull request, the requester cannot reopen, which seems unnecessarily unilateral. Surely we want an environment where contributions are given a fair chance as to encourage the contributor. There's no harm in leaving a pull request open for a few days. |
I hate to be the one who needs to decide here, as there are pros and cons going either way. FWIW the whole discussion would have been very different if we didn't have a string-based API. But as things are, the notion that we have two APIs one of which is a near-trivial wrapper over the other seems overengineered and creates a dangerous precedent. Let's let the forum discussion simmer a bit more. |
I thought that the compiler inferred those attributes now? Perhaps not. |
@andralex Well, you can leave it to others to decide if you want, but my vote is definitely no - not when we already have a
It does so for templates. Separate compilation makes it so that it won't work for normal functions. Neither |
Thanks for notifying me about this, @alexrp. I have joined the forum discussion rather than post here. |
Since this will likely not be merged that easily (it's been 5 months), I think it's best to attempt a DIP first. |
Um, is that a typo? It's silently converting an absolute path to a relative one. |
No update after 9 months. Closing due to inactivity. |
This adds a struct,
struct Path
, to std.path, which exposes a much more palatable interface to path string manipulation.Rationale for adding:
Some examples of how Path can be used:
Equality Testing:
Joining with other paths
Implicit conversion to a normalized path when passed as a string argument
Nice OO-style functions that make sense to have on the concept of a path
Plus, lots of other goodies. I encourage you to take a look at the unittests to get a feel for what the wrapper can do. If I overlooked something important, please let me know! I'd love for this to make it into the standard library. Forgive me if I haven't done a great job with the documentation; this was the first time I've had to use ddoc.