Subject: | Simpler way to specify :ATTR |
Hi,
Maybe I don't fully understand how to use Class::Std, but it seems verbose trying to build a class with many attributes. Since the init_arg, set, and get are all going to be using the same <tag>, why have to duplicate the effort? Seems like a recipe for a typo.
Instead of:
{
%name_of :ATTR(:init_arg<name> :get<name> :set<name>);
}
Do:
{
%name_of :ATTR(:as<name> :init_arg :get :set);
}
For example, below I have a simple class I'm creating, all the attributes are read and write, one has a default. Building with Class::Std the definition gets hairy (especially trying to keep the linesize < 80)
I would have supplied a patch, but didn't know where to begin once I started looking at the source to Class::Std
thanks
Jay
use Class::Std;use Class::Std;
{
%combo_legs_of :ATTR(init_arg=>combo_legs
:set<combo_legs> :get<combo_legs>);
%currency_of :ATTR(init_arg=>currency
:set<currency> :get<currency>);
%exchange_of :ATTR(init_arg=>exchange
:set<exchange> :get<exchange>);
%expiry_of :ATTR(init_arg=>expiry
:set<expiry> :get<expiry>);
%local_symbol_of :ATTR(init_arg=>local_symbol
:set<local_symbol> :get<local_symbol>);
%multiplier_of :ATTR(init_arg=>multiplier
:set<multiplier> :get<multiplier>);
%primary_exchange_of :ATTR(init_arg=>primary_exchange
:set<primary_exchange> :get<primary_exchange>);
%right_of :ATTR(init_arg=>right
:set<right> :get<right>);
%security_type_of :ATTR(init_arg=>security_type
:set<security_type> :get<security_type>);
%strike_of :ATTR(init_arg=>strike :default(0)
:set<strike> :get<strike>);
%symbol_of :ATTR(init_arg=>symbol
:set<symbol> :get<symbol>);
}