
David Abrahams wrote:
on Fri Jul 04 2008, Beman Dawes <bdawes-AT-acm.org> wrote:
David Abrahams wrote:
David Abrahams wrote:
FWIW, though I think it's probably a good idea to use base_name as you are suggesting, I was much less attached to the idea of using it to mean what is currently called leaf() than I was opposed to the idea of using it to mean something else, if you catch my drift :-) Ah! Understood.
So one other option that avoids the above issues (not that I'm pushing this route) is to pick another name for what you currently call leaf(). Let's say branch_path() is changed to parent_path(). That suggests a full set of names based on the parent/child decomposition of a path:
* Change branch() to parent_path() * Change leaf() to child() * Change basename() to child_prefix() * Change extension() to child_extension()
At first glance, those names seem reasonable clear and self-consistent.
What's your take on that set? Well, "parent" describes a relationship between the path being operated on and the result. "Child," on the other hand, does not. So that doesn't work for me. I would prefer "parent" and "filename." I would
Beman Dawes wrote: prefer "drop_extension" and "extension," although I rather liked Volodya's "stem" suggestion. I like "stem" too.
Trying to put that all together:
* Change branch() to parent_path()
Nit: "parent" is better. Sticking "path" in the name of a transformation that returns a path smacks of hungarian notation.
The point (besides consistency with some other decomposition function names) of adding _path is to emphasize that what parent_path("a/b/c") returns is "a/b" rather "a", "..", or going to the file system and finding out the parent path of "a". I'm no fan of hungarian notation!
* Change leaf() to file_name()
Are there any arguments other than personal preference for filename() vs file_name()? I was trying some code and kept writing filename(). Google code search turns up 5,980,00 hits for "filename" versus 550,000 for "file_name". So I think "filename" would win unless someone comes up with an argument otherwise. That should make you (Dave) happy as you've always spelled it "filename" in these discussions. I guess one argument is that "root_name" then looks inconsistent. I'm not worried about that enough to do anything about it --Beman