[Melbourne-pm] Timer::HiRes and alarms? (Was: AI Contest)

Toby Corkindale toby.corkindale at strategicdata.com.au
Wed Nov 10 23:40:19 PST 2010


On 11/11/10 18:22, Nathan Bailey wrote:
> On 11/11/2010, at 5:46 PM, Toby Corkindale wrote:
>> Yeah, it could definitely do with some improvements.
>> My Git repo holds a few by now, but only so far as improving the
>> existing methods.
>
> Nice! What does this line do (Planet.pm and Fleet.pm)?
> use overload '""' => sub { shift->PlanetID };

If you do
   warn "I am planet $planet";
then instead of printing "I am planet Planet(0xd34db33f)" it will print 
"I am planet 42", or whatever the actual ID is.

The overloaded "" operator means that it'll interpolate the result of 
that anonymous subroutine into strings using the object.


> Is there a reason you don't cache the distances (eg. in a hash?) -
> although I tried it, and NYTProf told me it was worse! :P

I am doing something like that actually.
However the code in the github repo is meant to be a "starter package", 
roughly matching the other languages' starter packages.

I don't want to start putting lots of extra methods in there, or else I 
and anyone using it might be disqualified. You're only allowed to have 
one entry per person, or if in a team, you're only allowed in one team, 
and not separately.
Publishing extra helpful code publicly could be seen as being part of 
many entries, if lots of people use it.




More information about the Melbourne-pm mailing list