develooper Front page | perl.perl5.porters | Postings from July 2011

Re: Why views are useful, and why their syntax doesn't matter much

Thread Previous | Thread Next
From:
Reverend Chip
Date:
July 13, 2011 22:30
Subject:
Re: Why views are useful, and why their syntax doesn't matter much
Message ID:
4E1E7F04.1070701@gmail.com
On 7/13/2011 9:28 PM, Jesse Luehrs wrote:
> On Wed, Jul 13, 2011 at 09:20:19PM -0700, Reverend Chip wrote:
>> I like them a lot; they're an obvious outgrowth of C<use strict> because
>> there's no point in typo checking "$a" but not "$a->{b}".  IMO, it's
>> obvious that Moose constructors should lock every object's hash after
>> construction (by default at least).  Otherwise there is no detection of
>> attribute typos.  Hm, I should write a MooseX for that.
> Moose takes the perspective of "you shouldn't ever be touching the
> instance structure directly anyway", which means there's nothing *to*
> typo (all accessors are generated, so they can't have typos, barring
> bugs in Moose). That said, this would be useful to have as a MooseX for
> things like conversion of legacy systems.

In point of fact it's legacy conversion that's my primary use case, so
that's all good.  OTOH, all protestations to the contrary, Perl's method
call mechanism is simply a lot slower than a direct hash lookup, even
with all the XS tricks that anyone has brought to bear until now.  So I
don't see a complete elimination of direct access any time soon.  OTGH,
these can be few enough that locking the hash might be seen by some as
excessive.  A MooseX is a reasonable middle ground.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About