line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package like; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
64423
|
use latest; |
|
2
|
|
|
|
|
10363
|
|
|
2
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
567
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2984
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
like - Declare support for an interface |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This document describes like version 0.02 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package MyThing; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use like qw( some::interface ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# later |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
if ( MyThing->isa( 'some::interface' ) ) { |
28
|
|
|
|
|
|
|
print "Yes it is!\n"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Allows a package to declare that it ISA named interface without that |
34
|
|
|
|
|
|
|
interface having to pre-exist. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
package MyThing; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use like qw( some::interface ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
is equivalent to |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package some::interface; # make the package exist |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package MyThing; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use vars qw( @ISA ); |
49
|
|
|
|
|
|
|
push @ISA, 'some::interface'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The like declaration is intended to declare that your package |
52
|
|
|
|
|
|
|
conforms to some interface without needing to have the consumer of that |
53
|
|
|
|
|
|
|
interface installed. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
There is no test that your package really does conform to any interface |
56
|
|
|
|
|
|
|
(see L); you're just declaring your intent. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub import { |
61
|
3
|
|
|
3
|
|
319
|
my ( $class, @isa ) = @_; |
62
|
3
|
|
|
|
|
13
|
my $caller = caller; |
63
|
2
|
|
|
2
|
|
90
|
no strict 'refs'; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
534
|
|
64
|
3
|
|
|
|
|
7
|
for my $isa ( @isa ) { |
65
|
3
|
50
|
|
|
|
3
|
@{"${isa}::ISA"} = () unless @{"${isa}::ISA"}; |
|
3
|
|
|
|
|
50
|
|
|
3
|
|
|
|
|
27
|
|
66
|
|
|
|
|
|
|
} |
67
|
3
|
|
|
|
|
5
|
push @{"${caller}::ISA"}, @isa; |
|
3
|
|
|
|
|
95
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |