Mercurial > pub > Impl
comparison Lib/IMPL/lang.pm @ 280:c6d0f889ef87
+IMPL::declare now supports meta attributes
*bugfixes related to the typeof() operator
| author | cin |
|---|---|
| date | Wed, 06 Feb 2013 02:15:48 +0400 |
| parents | 4ddb27ff4a0b |
| children | 77df11605d3a |
comparison
equal
deleted
inserted
replaced
| 279:af8af4b8337e | 280:c6d0f889ef87 |
|---|---|
| 4 | 4 |
| 5 use parent qw(Exporter); | 5 use parent qw(Exporter); |
| 6 use IMPL::_core::version; | 6 use IMPL::_core::version; |
| 7 use IMPL::clone qw(clone); | 7 use IMPL::clone qw(clone); |
| 8 use Scalar::Util qw(blessed); | 8 use Scalar::Util qw(blessed); |
| 9 use Carp qw(carp); | |
| 9 | 10 |
| 10 our @EXPORT = qw(&is &isclass &typeof); | 11 our @EXPORT = qw(&is &isclass &typeof); |
| 11 our %EXPORT_TAGS = ( | 12 our %EXPORT_TAGS = ( |
| 12 base => [ | 13 base => [ |
| 13 qw( | 14 qw( |
| 62 our @EXPORT_OK = keys %{ { map (($_,1) , map (@{$_}, values %EXPORT_TAGS) ) } }; | 63 our @EXPORT_OK = keys %{ { map (($_,1) , map (@{$_}, values %EXPORT_TAGS) ) } }; |
| 63 | 64 |
| 64 use IMPL::Const qw(:all); | 65 use IMPL::Const qw(:all); |
| 65 | 66 |
| 66 sub is($$) { | 67 sub is($$) { |
| 68 carp "A typename can't be undefined" unless $_[1]; | |
| 67 eval {ref $_[0] and $_[0]->isa( $_[1] ) }; | 69 eval {ref $_[0] and $_[0]->isa( $_[1] ) }; |
| 68 } | 70 } |
| 69 | 71 |
| 70 sub isclass { | 72 sub isclass { |
| 73 carp "A typename can't be undefined" unless $_[1]; | |
| 71 eval {not ref $_[0] and $_[0]->isa( $_[1] ) }; | 74 eval {not ref $_[0] and $_[0]->isa( $_[1] ) }; |
| 72 } | 75 } |
| 73 | 76 |
| 74 sub typeof(*) { | 77 sub typeof(*) { |
| 75 eval { $_[0]->typeof } || blessed($_[0]); | 78 eval { $_[0]->_typeof } || blessed($_[0]) || ref($_[0]) || $_[0]; |
| 76 } | 79 } |
| 77 | 80 |
| 78 sub public($) { | 81 sub public($) { |
| 79 my $info = shift; | 82 my $info = shift; |
| 80 $info->{access} = ACCESS_PUBLIC; | 83 $info->{access} = ACCESS_PUBLIC; |
