Today I really started to dig into Perl 6 and PIR. With some excellent IRC handholding from moritz++, I submitted a patch with the following code:
.sub 'trim' :method :multi(_) .local string s .local int start, end, temp, len .local int not_whitespace s = self start = 0 end = length s if end == 0 goto donetail loop: not_whitespace = is_cclass 32, s, start unless not_whitespace goto done inc start goto loop done: temp = end tail: dec temp not_whitespace = is_cclass 32, s, temp unless not_whitespace goto donetail end = temp goto tail donetail: len = end - start s = substr s, start, len .return(s) .end
It has some problems with the confusing double-negative and the magic number, but I've asked about this on the list. Aside from tests, documentation and some sample Perl 6 code (in Pugs), this will be my first "real" patch to Perl 6. I expect it won't get accepted as this is my first stab at it, but it made me feel good to finally get in and see what's going on.
The biggest obstacle? Remembering that this is high-level assembler and combining multiple statements doesn't work.
Update: Ah, sheesh. The 'not_whitepace' should be 'is_whitespace'. Patch resent.