For me, autobox is just that, a cool hack. It dosen't gain much, because all changes you're making are global changes, much like injecting methods into UNIVERSAL, which is not a good idea as well.
The one thing autoboxing buys you would be fancy syntax, but I don't see where the fancy syntax would make stuff nicer to read, and I imagine ugly/obfuscated stuff like this:
1->'1'(1 => 1)
The price we'd pay for autoboxing would be global class pollution, as people would wildly add methods to SCALAR, ARRAY and HASH, with all the name conflicts that usually happen then.
Class creation under Perl is only a bless away, and if you need special behaviour of your primitive datatypes, bless them into a class - Perl is not Java, where a class must reside in a different file, that is appropriately named, and we don't even need to decide on the class name at implementation name. If you want fancy stringification etc., overload buys us that, the only thing that's ugly to implement is fancy HASH or ARRAY semantics, which could be bought by tie (although, there is a price to pay).
For specialized small projects, clever autoboxing could simplify the code, but for anything over 100 lines, the special behaviour is better moved into its own class IMHO.
perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
In reply to Re: Autoboxing: Yes or No?
by Corion
in thread Autoboxing: Yes or No?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |