Re: dear lazyweb: method-enriched ArrayRef, etc

[email protected] (Yuval Kogman)
Newsgroups perl.moose
Message-ID <[email protected]>
Moose::Autobox

On Fri, Feb 08, 2008 at 19:35:36 -0500, Ricardo SIGNES wrote:
> 
> I want a ArrayRefish type that acts like Object::Array, and maybe a HashRefish
> type that acts like Object::Hash.  I want to be able to push and splice my
> arrays, this sucks:
> 
>   push @{ $object->relatives }, $value;
> 
> MXAH doesn't make it much better, in my opinion:
> 
>   $object->push_relatives, $value;
> 
> Sure, there's no ugly syntax, but now I have one method per (op x attr), and I
> probably have to set those up manually more often than I want.
> 
> I'd rather type:
> 
>   $object->relatives->push($value);
> 
> Heck, with this I can even (mostly) keep an auto_deref-like behavior by
> returning that sort of value when called in list context, since all the method
> calls will be imposing scalar context.  This will be weird:
> 
>   my $scalar = $object->relatives;
> 
> ...but I don't mind relying on social pressure and the plurality of the
> attribute name to force me to pay more attention.
> 
> Obviously, these should be able to auto-upgrade from stock $whatever references
> when set.
> 
> -- 
> rjbs



-- 
  Yuval Kogman <[email protected]>
http://nothingmuch.woobling.org  0xEBD27418
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.