dear lazyweb: method-enriched ArrayRef, etc
[email protected] (Ricardo SIGNES)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
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
signature.asc
(application/pgp-signature, 194 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkes9VgACgkQHu6P14fNXHM7MgCfVuQppB5RhO1IgN+XiZ9VhXYG CdgAn2Sjzv27bIPnYkz8hH7DswEXraV3 =bwqf -----END PGP SIGNATURE-----