SPVM::Cloner(3)
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 & License π
- 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
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms