Since I missed a couple of Rakudo days in the middle of last month, thanks to the excellent Nordic Perl Workshop and the hackathon that followed it, I did an extra one today to get caught up with them a bit and to keep things moving.
I did a first cut of enums quite a while ago. Since then, a lot of things in Rakudo have changed, parts of the spec became clear and, well, the first cut of enums just wasn't that good. Sometimes you gotta get something wrong as a precursor to getting it right, or at least righter.
The end result is pleasing in that actions.pm is now a lot shorter, since we construct enums in a quite different way. A bunch of code that only hung around because the previous enums implementation needed it has gone away. Also, the code that the compiler generates for enums is vastly more compact; the heavy lifting is done in a different place. It's also been easier to add a bunch of the missing stuff that people were asking for, and various other bugs just evaporated.
Now, for enum elements, you can introspect them some more:
enum Day <Mon Tue Wed Thu Fri Sat Sun>;
say Mon.name; # Mon
say Mon.perl; # Day::Mon
say Min.WHAT; # Day - not just the string, but Day itself
Smart-matching now works too. So if you have some variable $thingy that has had Day mixed into it an initialied, you can do things like:
given $thingy {
when Mon { say "yaaaaawwwwn" }
when Tue|Wed|Thu { say "work work work" }
when Fri { say "w00t, nearly the weekend" }
when Sat { say "OH HAI I'M AT THE BAR" }
when Sun { say "good morning, vicar" }
}
You can also do
There's still some more bits to do, but enums should now be greatly improved in Rakudo. There's a couple more tickets, and I'm sure others will help flesh out the weaknesses of this new implementation, so we can shake out the bugs.
I also dealt with a few other bits and pieces.
my $cheapest = @products.min(*.price);
Which is kinda cute.Thanks to Vienna.pm for sponsoring this Rakudo Day.
A large wall of beer loomed overhead ... (Score:1)
Why don't you do a Perl 6 one ?
Please let me know if this would be an interesting paid project (& what you'd estimate it would take)
Re: (Score:1)