has 'x' => (is => 'rw', isa => 'Int');
has 'x' => {is => 'rw', isa => 'Int'};
The second syntax is more righteous
Some times some people say TIMTOWTDI. But in this case there is just one way better than another
I'm gonna tell ya the reasons
First, the second syntax is faster than first one because you pass one string and just one hash reference while first syntax passes one string and list of law key value pairs. In the first case, the subroutine probably does something like:
my ($propname,%options)=@_This is just wasteful isn't it? You make list of key value pairs and copy to @_, and copy again to %options.
But in the second case, you only make list once and what you copy is just a reference.
When you make a big program which uses a lot of classes, the second syntax would be more efficient
Second, inconsistencies.
There are so many module which uses first syntax and there also second syntax.
That leads users into confusion because of inconsistencies of syntaxes. for example the module 'Template' uses second syntax in 'process' subroutine
use Template;
# some useful options (see below for full list)
my $config = {
INCLUDE_PATH => '/search/path', # or list ref
INTERPOLATE => 1, # expand "$var" in plain text
POST_CHOMP => 1, # cleanup whitespace
PRE_PROCESS => 'header', # prefix each template
EVAL_PERL => 1, # evaluate Perl code blocks
};
# create Template object
my $template = Template->new($config);
# define template variables for replacement
my $vars = {
var1 => $value,
var2 => \%hash,
var3 => \@list,
var4 => \&code,
var5 => $object,
};
# specify input filename, or file handle, text reference, etc.
my $input = 'myfile.html';
# process input template, substituting variables
$template->process($input, $vars)
|| die $template->error();
The laziness of not typing two characters '{' and '}' make bigger problem called 'inconsistency'
So what I want to say is: Moose must support at least both syntaxes
PS: It seems that here are so many emotional people. And you even don't give me logical answers.And taste is not a matter of programming. It is matter of food or something. Please find taste in other places