Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Moose 'clone' Constructor

by Corion (Patriarch)
on Jul 04, 2018 at 07:56 UTC ( [id://1217860]=note: print w/replies, xml ) Need Help??


in reply to Moose 'clone' Constructor

I see MooseX::Clone, which implements more cloning support, but alludes to some bare-bones cloning support in Moose. If I read the discussion right, cloning in Moose is just:

bless { %$old }, ref $old;

... but I don't know if there is a default constructor ->clone() provided.

Replies are listed 'Best First'.
Re^2: Moose 'clone' Constructor
by kcott (Archbishop) on Jul 04, 2018 at 10:40 UTC

    G'day Corion,

    ++ Thanks for that. MooseX::Clone looks interesting. Its abstract does say "Fine-grained cloning support", and it looks like there could be a fair bit of work setting this up. Perhaps useful in situations where specific custom cloning was wanted. I also note a TODO section: I tend to be a bit wary of those as it suggests incomplete functionality — might wait for that to become TODONE. :-)

    With a bit of link-hopping from there, I came across "Class::MOP::Class - Object instance construction and cloning". The clone_object() method appears less fine-grained (than MooseX::Clone) and perhaps more useful as a general solution.

    Both of those have example code for setting up a clone() method in your own class.

    As I said in the OP, not an immediate requirement but I'll keep both of those in mind. Thanks again.

    — Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found