Created
September 12, 2011 21:30
-
-
Save dams/1212507 to your computer and use it in GitHub Desktop.
different approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub Mo'import { | |
import warnings; $^H |= 0x602; | |
my $p = caller."'"; | |
@_ = ( ISA, extends, has, sub { | |
my ( $n, %a ) = @_; | |
my $d = $a{default}||$a{builder}; | |
*{ $p . $n } = $d | |
? sub { | |
$#_ ? $_[0]{$n} = $_[1] | |
: exists $_[0]{$n} ? $_[0]{$n} | |
: ( $_[0]{$n} = $_[0]->$d ) | |
} | |
: sub { $#_ ? $_[0]{$n} = $_[1] : $_[0]{$n} } | |
}, sub { @{ $p . ISA } = $_[0]; eval "no $_[0] ()" }, [Mo'_]); | |
*{ $p.$_ } = pop for @_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment