Re: Nice-to-have class methods
On Wed, Jan 27, 2016 at 7:09 AM, Elizabeth Mattijsenwrote: >> On 27 Jan 2016, at 14:00, Tom Browder wrote: >> >> Given so many handy methods for built-in classes, it would be nice to have a >> couple of more for some, for instance: >> >> IO:Path.stemname >> Like basename except any suffix is removed > > Seems like a nice idea. I've found the pertinent bits and added necessary code (no docs or tests yet) in the Rakudo source, and I've filed a feature request via e-mail to . I've also made a pull request. But how does such a feature request really work when the Perl 6 spec, as I understand it, is frozen for now. Isn't a new method a spec change? Best regards, -Tom
RE: Nice-to-have class methods
From: Tom Browder [mailto:tom.brow...@gmail.com] > > Given so many handy methods for built-in classes, it would be nice to have a > couple of more for some, for instance: > > IO:Path.stemname > Like basename except any suffix is removed > > IO::Handle.say (or println) > Like print except with an added newline. A way to tell if an IO-type handle (so socket, filehandle, pipe etc) is seekable. [Apologies in advance if it already exists & I’ve missed it] Paul
Re: Nice-to-have class methods
On Wed, Jan 27, 2016 at 7:09 AM, Elizabeth Mattijsenwrote: >> On 27 Jan 2016, at 14:00, Tom Browder wrote: >> >> Given so many handy methods for built-in classes, it would be nice to have a >> couple of more for some, for instance: ... >> IO::Handle.say (or println) >> Like print except with an added newline. > > IO::Handle already has a .say ? Oops, the docs confused me. say is only mentioned as a role sub while print is mentioned as both method and role sub for IO::Handle. It works fine, though. Thanks, Liz. Cheers! -Tom P.S. Do you or any other Perl 6 developers plan to attend the recently-announced YAPC::NA in Orlando, Florida, in June? I hope so because I plan to attend only if there are significant Perl 6 events.
Re: Nice-to-have class methods
On Wed, Jan 27, 2016 at 02:14:17PM +, Philip Hazelden wrote: > On Wed, Jan 27, 2016 at 1:43 PM Peter Pentchevwrote: > > > On Wed, Jan 27, 2016 at 07:00:11AM -0600, Tom Browder wrote: > > > Given so many handy methods for built-in classes, it would be nice to > > have > > > a couple of more for some, for instance: > > > > > > IO:Path.stemname > > > Like basename except any suffix is removed > > > > Hmm, this sounds like a nice idea on a first glance, but then again, > > can you tell me exactly what situations would that be useful for? > > Is it for compressed files (e.g. .zip vs .tar.gz) or MS-DOS/Windows > > executables (.com, .exe, .bat), or something else? > > When I strip filename extensions, I usually know exactly what extensions > > I want to strip - e.g. ".conf" or ".pl" or something like that. There > > are very, very rare cases when any extension should be stripped - and > > there's also a problem with that. [snip my explanation of a problem with removing everything after the first dot] > > For a "convert files to $format" thing, you'd want to replace the > extension. You don't need to specify the previous extension(s) if it's a > quick-and-dirty thing where you know everything passed to it will be > acceptable; and you don't want to, if you're passing out to some other > service which can handle various input formats. (e.g. a wrapper around > ffmpeg or ImageMagick or something - they can handle a lot of filetypes > with a lot of likely extensions.) Right, so that would probably mean that you need a function that removes the *last* extension; that might indeed make sense, although it's trivial to implement as a regular expression substitution (but also beware the case of a filename with no dots at all). G'luck, Peter -- Peter Pentchev r...@ringlet.net r...@freebsd.org p...@storpool.com PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 signature.asc Description: PGP signature
Re: Nice-to-have class methods
> On 27 Jan 2016, at 14:00, Tom Browderwrote: > > Given so many handy methods for built-in classes, it would be nice to have a > couple of more for some, for instance: > > IO:Path.stemname > Like basename except any suffix is removed Seems like a nice idea. > IO::Handle.say (or println) > Like print except with an added newline. IO::Handle already has a .say ? $ 6 '$*OUT.say("hello world")' hello world Liz
Re: Nice-to-have class methods
On Wed, Jan 27, 2016 at 07:00:11AM -0600, Tom Browder wrote: > Given so many handy methods for built-in classes, it would be nice to have > a couple of more for some, for instance: > > IO:Path.stemname > Like basename except any suffix is removed Hmm, this sounds like a nice idea on a first glance, but then again, can you tell me exactly what situations would that be useful for? Is it for compressed files (e.g. .zip vs .tar.gz) or MS-DOS/Windows executables (.com, .exe, .bat), or something else? When I strip filename extensions, I usually know exactly what extensions I want to strip - e.g. ".conf" or ".pl" or something like that. There are very, very rare cases when any extension should be stripped - and there's also a problem with that. You see, I was kind of surprised many years ago when I first met somebody who routinely used a dot as a word separator in filenames - a file that I would've called "yearly-report.txt" or "YearlyReport.txt", he would call "yearly.report.txt". Over the years after that, I stumbled into many other people who do that - not a majority, certainly, but, well, many people indeed. So a function that would remove *any* filename extensions, that is, anything after and including the first dot, would produce really weird results if applied to filenames created by such people. G'luck, Peter -- Peter Pentchev r...@ringlet.net r...@freebsd.org p...@storpool.com PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 signature.asc Description: PGP signature
Re: Nice-to-have class methods
On Wed, Jan 27, 2016 at 9:50 AM, Peter Pentchevwrote: > Right, so that would probably mean that you need a function that removes > the *last* extension; that might indeed make sense, although it's > trivial to implement as a regular expression substitution (but also beware > the case of a filename with no dots at all). > Or starting with a dot (Unix), or even all-dots (someone called it on . or .. for some reason). -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net