| 1 | package SPVM::Cloneable; | ||
| 2 | |||
| 3 | 1; | ||
| 4 | |||
| 5 | =head1 Name | ||
| 6 | |||
| 7 | SPVM::Cloneable - Interface Type to Clone Object | ||
| 8 | |||
| 9 | =head1 Description | ||
| 10 | |||
| 11 | The Cloneable interface in L<SPVM> represents a cloneable interface. | ||
| 12 | |||
| 13 | =head1 Usage | ||
| 14 | |||
| 15 | class Point { | ||
| 16 | interface Cloneable; | ||
| 17 | |||
| 18 | method clone : Point () { | ||
| 19 | |||
| 20 | my $new_point = Point->new($self->x, $self->y); | ||
| 21 | |||
| 22 | return $new_point; | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | =head1 Interface Methods | ||
| 27 | |||
| 28 | =head2 clone | ||
| 29 | |||
| 30 | C<required method clone : object ();> | ||
| 31 | |||
| 32 | The implementation must return the cloned object. | ||
| 33 | |||
| 34 | =head1 Copyright & License | ||
| 35 | |||
| 36 | Copyright (c) 2023 Yuki Kimoto | ||
| 37 | |||
| 38 | MIT License |