SPVM::Cloner(3)

πŸ“¦ version 0.990125, in alpine 3.24

hey bestie πŸ’– welcome to SPVM::Cloner(3), fresh out of the User Contributed Perl Documentation section. this one is the interface type for the callback to clone an object, and it's lowkey iconic. let's get into it πŸŽ€

🌸 Name 🌸

SPVM::Cloner β€” Interface Type for the Callback to Clone a Object

okay so that's the whole name, no cap. it's giving "callback but make it a type" ✨

πŸ¦‹ Usage πŸ¦‹

here's the vibe check πŸ‘‡

         use Cloner;
         use Point;

         my $cloner = (Cloner)method : object ($object : object) {
           my $point = (Point)$object;

           my $cloned_point = Point->new($point->x, $point->y);

           return $cloned_point;
         };

         my $point = Point->new(1, 2);
         my $cloned_point = $cloner->($point);

you make a Cloner callback, then call it on your Point, and boom πŸ’… β€” cloned point acquired. main character behavior, fr fr.

πŸ”₯ Description πŸ”₯

Cloner is the interface type for the callback to clone an object. basically: a callback whose entire job is "give me an object, I give you the clone." periodt πŸ’–

πŸ’… Interface Methodss πŸ’…

  • required method : object ($object : object); β€” your implementation must receive an object and return the cloned object. that's the whole assignment, bestie 🫢

πŸ‘‘ Class Methods πŸ‘‘

  • static method default_cloner : Cloner (); β€” returns a default cloner. slay πŸ’…

The implementation of the default cloner is

         method : object ($object : Cloneable) {

           my $clone = (object)undef;

           if ($object) {
             $clone = $object->clone;
           }

           return $clone;
         };

If the object $object is undef, returns undef, ohterwise calls the Cloneable#clone method and its return value. (yes, the manpage says ohterwise β€” I'm not fixing it, I'm just reporting it πŸ’€)

  • Copyright (c) 2023 Yuki Kimoto
  • MIT License

okay that's the page, bestie! πŸ’– this version is based on perl v5.42.2, dated 2026-02-03, and the footer says SPVM::Cloner(3) β€” periodt 🫢✨

πŸ“¦ where this page comes from