Closed benjreinhart closed 10 years ago
fs purposely avoids returning strings from its functions because it encourages people to pass around string paths when they should just be using file objects. If you pass around strings they're just going to get wrapped in File objects anyways.
If you don't want a string back, this function is the already existing file
function. Just call it on multiple args and you get back a joined File object.
What are the compelling reasons to have a join
function that returns a string?
@Raynes I think it's a Ruby thing (ie. File.join
). Could be wrong. Shame me if I am!
@Raynes in our project we are building up lists of file paths before we actually do anything with them. Though, now that I look over our code, it could be restructured to make better use of working with file objects instead.
One use case I can think of would be a CLI tool that accepts file paths for one reason or another. This interface must accept strings. This example might sound rare, but I bring it up because I have a couple of libraries that work with paths through a CLI (though they are not written in clojure).
I agree maybe this isn't necessary. In the languages I'm most familiar with (JavaScript, Ruby) join
is a common function, made available in standard libs. I also see that python provides this as well.
Ahh, I realize now that I said that the CLI tool obviously accepts strings but could probably just use the file
function.
Yeah, I think you're right, seems as though the file
function should suffice.
Going ahead and closing this since I think we came to an agreement that no action was necessary.
+1