Mercurial > pub > Impl
changeset 177:df71a307ef9b
new constructor syntax
author | sourcer |
---|---|
date | Wed, 12 Oct 2011 00:04:13 +0300 |
parents | 74c27daf2e7b |
children | 658a80d19d33 |
files | .includepath Lib/IMPL/lang.pm |
diffstat | 2 files changed, 25 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/.includepath Wed Oct 05 16:23:45 2011 +0400 +++ b/.includepath Wed Oct 12 00:04:13 2011 +0300 @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="UTF-8"?> -<includepath> - <includepathentry path="${resource_loc:/Impl/Lib}" /> -</includepath> - +<?xml version="1.0" encoding="UTF-8"?> +<includepath> + <includepathentry path="${resource_loc:/Impl/Lib}" /> +</includepath> +
--- a/Lib/IMPL/lang.pm Wed Oct 05 16:23:45 2011 +0400 +++ b/Lib/IMPL/lang.pm Wed Oct 12 00:04:13 2011 +0300 @@ -38,6 +38,8 @@ &property &static &property + &ctor + &base ) ], compare => [ @@ -117,6 +119,24 @@ $class->static_accessor( $name, $value ); } +sub ctor(&;$) { + my ( $code, $base ) = @_; + no strict 'refs'; + my $class = caller; + + if ($code) { + *{"${class}::CTOR"} = $code; + } + + if (ref $base eq 'HASH') { + %{"${class}::CTOR"} = %$base; + } +} + +sub base($) { + return shift; +} + sub equals { if (defined $_[0]) { return 0 if (not defined $_[1]);