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
(1) add method IO::Path.stemname; (2) expand method IO::Path.parts #5097
Comments
From @tbrowderClass IO:Path currently has many methods for handling path name. The method abspath I would like to see a new method named, say, stemname, which would be # existing method: basename
# existing method: extension
# new method: stemname
# updated old method: parts
Best regards, -Tom |
From @smls
Isn't that what the word `basename` conveys too? After all, the purpose of the well-known `basename` POSIX utility is to return the filename with its suffix stripped. It's just that it doesn't guess what you want to consider a suffix, so it strips nothing as an edge case when no suffix list is specified. I'd thus consider the Perl 6 `.basename` method a misnomer, since its purpose is to always return the whole filename. Ideally, Perl 6 would provide: `.filename` -- whole filename I suppose `.stemname` is a decent synonym for `.basename`, so a plan forward without much backwards compatibility breakage could be: 1) Introduce `.stemname` as this RFC suggests. (Another candidate for deprecation would be `.dirname`, since AFAICT it's redundant with the much more clearly named .parent. And lets not even get into `.abspath` and `absolute` both existing, and the inconsistency of some routines returning paths as IO::Path and others returning paths as Str. Yeah, there's a lot of cleanup potential in the IO parts of the language...:P) |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetOn Thu, 28 Jan 2016 10:45:04 -0800, tbrowder wrote:
Thanks for the suggestion, however, I'm going to reject this RFC. You showed the most common example—a single part extension—but it has the same limitations as the old .extension method (e.g., I'd expect the "stemname" of "foo.tar.gz" to be "foo" not "foo.tar"). As of Rakudo 2017.04.2, you can use .extension method remove the extension, removing however many parts you want to remove, and you can then call .basename on the returned path to get the "stemname": "docs/README.pod".IO.extension("").basename.say "docs/foo.tar.gz".IO.extension("", :2parts).basename.say' |
@zoffixznet - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#127407 (status was 'rejected')
Searchable as RT127407$
The text was updated successfully, but these errors were encountered: