Class::Closure

I’ve released the first segment of Glop to the CPAN, and it’s called Class::Closure. It’s not directly related to games, but it is in a yak-shaving sort of way. Perl’s class syntax sucks, most Perl programmers agree on that. Both creating a basic class and referring to its members is a pain. So I wrote Class::Closure, which fixes that without using a source filter (if you want it with an ugly source filter, see my Perl6::Classes).

But another thing that games require more than anything else is speed. So I did some benchmarks on Class::Closure, and found that its dispatch was about 4 times slower than the generic object model. Acceptable, but not optimal. I did a few caching tests, and one of them proved promising. If I cached the methods in the class’s symbol table, it turned out to be faster than the traditional object model. So I switched over the whole module to create a new symbol table for each object instead of storing it in a hash, and it’s about twice as fast as the traditional model. As an added bonus, it cleaned up the inheritance scheme somewhat.