On Sat, Jan 24, 2009 at 09:27:04AM -0800, Ovid wrote: > You know, I rewrote .trim as: > > .sub 'trim' :method :multi(_) > .local string s > s = self > s = 'trim_start'(s) > s = 'trim_end'(s) > .return(s) > .end > > I thought about the performance issue but opted for correctness and "no > duplicate code". I figured it's trivial to speed up later, if need be.
Yes. Definitely "correctness" comes before "optimisation" > I'd still opt for removing .chop, though. I think only once have I ever seen > it used appropriately. All other times the user wanted .chomp. I've used it intentionally, but only because it's less typing than s/.\z//m; (or whatever the canonically correct Perl 5 equivalent is) The Perl 6 version is 1 character terser? Nicholas Clark