in reply to Re: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
in thread Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI ;)

> The arrow does not work on lists nor arrays (it imposes scalar context, so it operates on the last member or size, respectively):

Sadly yes, thats one advantage of autobox, were (IIRC¹) one needs to overload arrow to achieve this.

OTOH it's far faster then a normal method call, there is no inheritance chain look-up at run time.

Another important difference is that a method "pollutes" the variable namespace, i.e. variables called '$grep' could cause conflicts.

Also importing lexical variables from packages won't be easy ( while I can imagine an eval -hack in importer). So importing such methods could lead to package vars.

But "Pro" or "Con" depends on the perspective.

If the intention is to port an OO language like JS or Ruby and to reflect syntax and semantic this should be a cool approach, since most of those languages have no separate namesspaces (no sigils!)

Another use case is to have local ad-hoc wrapper methods for objects w/o manipulating corresponding classes.

Cheers Rolf

( addicted to the Perl Programming Language)

Update

¹) at least thats what I figured out the last time I looked into it, but my Perl foo was limited back then..

  • Comment on Re^2: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
  • Download Code