Object-Lexical
view release on metacpan or search on metacpan
package Object::Lexical;
use 5.008;
use strict;
use warnings;
our $VERSION = '0.02';
use PadWalker;
my $counter = 0;
my $opt_wrap = 1;
my $opt_export = 1;
my $opt_nonlex = 1;
my %methods = ();
sub instance {
*{$target} = sub { *{$thisglob} = shift; goto &$code; };
} else {
*{$target} = $code;
}
undef *{$source};
}
}
# move lexically defined subs, too
my $pad = PadWalker::peek_my(1);
foreach my $x (keys %$pad) {
my $code = ${$pad->{$x}};
next unless ref($code) eq 'CODE';
substr($x, 0, 1, ''); # remove sigil
my $target = $package.'::'.$x;
my $thisglob = $package.'::this';
if($opt_wrap) {
*{$target} = sub { *{$thisglob} = shift; goto &$code; };
} else {
*{$target} = $code;
=cut
#
# what if... methods were declared using some method 'foo' = sub { ... }; syntax
# (method() being lvalue) at the top level, and a lexical references module or
# B::Generate were used to minipulate, runtime, which lexicals each saw, so
# code references could be copy, configured, and populated into namespaces?
#
#
# Lexical::Alias and PadWalker and AUTOLOAD together could do this:
# use the old-style hash dispatch logic, but before dispatching, each lexical
# in the PAD of the code reference would be aliased to a lexical stored in
# the per object hash.
#
# ie, given a blessed hash, $foo = { }, $foo->{my_method} might reference $a and $b.
# these would be aliased to $foo->{a} and $foo->{b} for that invocation
#
#
# changes
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Object-Lexical
version: 0.02
version_from: Lexical.pm
installdirs: site
requires:
PadWalker: 0.08
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.10_07
Makefile.PL view on Meta::CPAN
use 5.008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Object::Lexical',
'VERSION_FROM' => 'Lexical.pm', # finds $VERSION
'PREREQ_PM' => { PadWalker => 0.08 }, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'Lexical.pm', # retrieve abstract from module
AUTHOR => 'Scott Walters <scott@slowass.net>') : ()),
);
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules and libraries:
PadWalker
COPYRIGHT AND LICENCE
Copyright (C) 2003, Scott Walters
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
( run in 0.728 second using v1.01-cache-2.11-cpan-05444aca049 )