Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Moose Trait to Add a Method to an Attribute ( Moose/Meta/Method/Accessor/Native/Array/apply.pm )

by choroba (Cardinal)
on Oct 08, 2016 at 09:20 UTC ( [id://1173526]=note: print w/replies, xml ) Need Help??


in reply to Re: Moose Trait to Add a Method to an Attribute ( Moose/Meta/Method/Accessor/Native/Array/apply.pm )
in thread Moose Trait to Add a Method to an Attribute

Thanks a lot! It's definitely a step in the right direction. But it modifies the Array trait globally, instead of creating a new one. _potential_value is not only confusing/disgusting, but also private and undocumented :-(

I inspected some other methods in the same directory (e.g. map), which uses _return_value instead, but sort_in_place is much better because it shows how to modify the elements of the list. Thank again for pointing me to it. However, it still doesn't really modify the values in place: it returns a reference to a new anonymous array containing the new values.

Update: I had to quotequote InvalidArgumentToMethod in the code, otherwise I got

> Could not create writer for list because Failed to compile source: Bareword "InvalidArgumentToMethod" not allowed while "strict subs" in use at native delegation method My::apply_to_list (apply) of attribute list

$self->_inline_throw_exception( '"InvalidArgumentToMethod"' => 'argument => $_[0],'. 'method_name => "apply",'. 'type_of_argument => "code reference",' +. 'type => "CodeRef",',

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
  • Comment on Re^2: Moose Trait to Add a Method to an Attribute ( Moose/Meta/Method/Accessor/Native/Array/apply.pm )
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1173526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-23 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found