Skip Menu |

This queue is for tickets about the Class-Accessor-Array CPAN distribution.

Report information
The Basics
Id: 113423
Status: open
Priority: 0/
Queue: Class-Accessor-Array

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Shorter declaration for the common case
For the common case (i.e. indexing starts at zero and there are no "holes") it would be nice if there is a shorter accessor declaration without the need to specify the indexes. For example, the example from Class-Accessor-Array's synopsis could be written as: package Your::Class; use Class::Accessor::Array { accessors => [qw(foo bar)], };
On Tue, 29 Mar 2016 07:24:35 GMT, SREZIC wrote: Show quoted text
> For the common case (i.e. indexing starts at zero and there are no > "holes") it would be nice if there is a shorter accessor declaration > without the need to specify the indexes. For example, the example from > Class-Accessor-Array's synopsis could be written as: > > package Your::Class; > use Class::Accessor::Array { > accessors => [qw(foo bar)], > };
Agreed. However... I plan to be reasonably compatible with Class::XSAccessor::Array. Aside from attributes, CXA also has getters, setters, predicates, lvalue_accessors, and perhaps I want to support them too someday. How would you reconcile cases like: package Your::Class; use Class::Accessor::Array { accessors => [qw(foo bar)], getters => [qw(one two)], }; BTW, this special form is even shorter: package Your::Class; use Class::Accessor::Array ['foo', 'bar']; or perhaps: package Your::Class; use Class::Accessor::Array 'foo', 'bar'; I don't know which ones to support yet. The Class::Accessor modules "family" are sort of compatible with one another but there are enough incompatibilities among them.
On 2016-03-29 05:21:37, PERLANCAR wrote: Show quoted text
> On Tue, 29 Mar 2016 07:24:35 GMT, SREZIC wrote:
> > For the common case (i.e. indexing starts at zero and there are no > > "holes") it would be nice if there is a shorter accessor declaration > > without the need to specify the indexes. For example, the example > > from > > Class-Accessor-Array's synopsis could be written as: > > > > package Your::Class; > > use Class::Accessor::Array { > > accessors => [qw(foo bar)], > > };
> > Agreed. However... > > I plan to be reasonably compatible with Class::XSAccessor::Array. > Aside from attributes, CXA also has getters, setters, predicates, > lvalue_accessors, and perhaps I want to support them too someday. How > would you reconcile cases like: > > package Your::Class; > use Class::Accessor::Array { > accessors => [qw(foo bar)], > getters => [qw(one two)], > }; > > BTW, this special form is even shorter: > > package Your::Class; > use Class::Accessor::Array ['foo', 'bar']; > > or perhaps: > > package Your::Class; > use Class::Accessor::Array 'foo', 'bar'; > > I don't know which ones to support yet. The Class::Accessor modules > "family" are sort of compatible with one another but there are enough > incompatibilities among them. >
Prior art: there's the CPAN module accessors.pm which also uses the simple list syntax: use accessors qw(foo bar);