Assign method call to hash value?

Daniel Perrett perrettdl at googlemail.com
Tue Jan 29 22:28:24 GMT 2013


Apologies: so after consultation with #perl on IRC, my question has
been answered - Moose (for reasons I don't yet know) does stuff like

has 'foo' => ( is => 'rw' )

which would incorrectly be treated as

has 'foo' => 'rw'

So ignore my previous post.

Daniel

On 29 January 2013 21:12, Daniel Perrett <perrettdl at googlemail.com> wrote:
> =head1 TANGENT
>
> ... about the design of context in perl.
>
> I get how you can do things like {%original, %changes}, but is there a
> reason why the => couldn't add some magic and assume scalar context on
> whatever it precedes? The only case I imagine it would break would be
> a hypothetical {%original,  key=> @odd_list }, but I don't know why
> anyone would do that.
>
> On 29 January 2013 14:18, gvim <gvimrc at gmail.com> wrote:
>> On 29/01/2013 14:09, pierre masci wrote:
>>>
>>>
>>> And (tell me if i'm wrong) it's also equivalent to this:
>>>
>>> my %result_hash = ( 'passed', $passed, 'valid', $r->valid, 'missing',
>>> $r->missing, 'invalid', $r->invalid, 'unknown', $r->unknown );
>>> return \%result_hash;
>>>
>>> where the brackets clearly show that it's a list.
>>>
>>
>> The hash = list is not where my confusion originated. It came more from the
>> fact that the list is still a list of scalars so I couldn't understand why
>> adding another element to the list did not invoke a scalar context, that's
>> all. Anyway, Dave Cross cleared it up, thanks.
>>
>> gvim


More information about the london.pm mailing list