Perl6-Binding

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         Perl6-Binding
version:      0.601
version_from: lib/Perl6/Binding.pm
installdirs:  site
requires:
    Filter::Util::Call:            1.0601
    PadWalker:                     0.10
    Text::Balanced:                1.95

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

Makefile.PL  view on Meta::CPAN

use 5.006;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME              => 'Perl6::Binding',
    VERSION_FROM      => 'lib/Perl6/Binding.pm', # finds $VERSION
    PREREQ_PM         => {
    	'PadWalker'		=>	'0.10',
    	'Filter::Util::Call'	=>	'1.0601',
    	'Text::Balanced'	=>	'1.95',
    }, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/Perl6/Binding.pm', # retrieve abstract from module
       AUTHOR         => 'Kevin Michael Vail <kevin@vaildc.net>') : ()),
    LIBS              => [''], # e.g., '-lm'
    DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
    INC               => '-I.', # e.g., '-I. -I/usr/include/other'
	# Un-comment this if you add C files to link with later:

README  view on Meta::CPAN

    my ($foo, @bar, %baz) := @hash{qw/foo bar baz/};

This version is still an alpha version, released so that I can get some feedback
on bugs and on the general functionality of the module.

Version 0.02 fixed some minor problems.

Version 0.03 gets the prerequisites right in Makefile.PL.

Version 0.04 corrects a number of bugs, and updates the prerequisite
for PadWalker to 0.09.

Version 0.05 checks to see if a hash element exists before attempting
to create an alias for it, and modifies the tests to skip several of them
due to a problem in PadWalker with Perl 5.8.x.

Version 0.06 fixes a long-standing problem with bindings in recursive
subroutines. Basically, the underlying XS code was always binding the variable
in the first call, not the one at the current stack level.

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

    Filter::Util::Call
    Text::Balanced
    PadWalker

COPYRIGHT AND LICENCE

Copyright 2003-2004 Kevin Michael Vail

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. 

lib/Perl6/Binding.pm  view on Meta::CPAN


package Perl6::Binding;
use strict;
use warnings;
our $VERSION = '0.601';
require XSLoader;
XSLoader::load('Perl6::Binding', $VERSION);

use Filter::Util::Call;
use Text::Balanced qw(extract_bracketed);
use PadWalker;
use Carp;

our %INSTALLED;

=head1 NAME

Perl6::Binding - implement Perl6 aliasing features

=head1 SYNOPSIS

lib/Perl6/Binding.pm  view on Meta::CPAN

Version 0.601 is an update to 0.6 that puts the dependencies back into the Makefile.PL.

=back

=head1 REQUIRED MODULES

L<Filter::Util::Call|Filter::Util::Call>

L<Text::Balanced|Text::Balanced>

L<PadWalker|PadWalker>

=head1 BUGS

Under Perl 5.8.x, it is not possible to create aliases at the root level
of the program due to a problem in PadWalker 0.09 and 0.10 (see the README
for PadWalker).  Aliases created in subroutines continue to work, however.

=head1 ACKNOWLEDGEMENTS

Some code was taken from Devel::LexAlias and Devel::Caller, both by Richard
Clamp.

The name Perl6::Binding was suggested by Benjamin Goldberg.

=head1 AUTHOR

lib/Perl6/Binding.pm  view on Meta::CPAN

## references.  Each of these contains two or more elements. The first is 0
## for the normal case or 1 for a flattened case, or 2 if the original item
## is a hash or array slice. If the first element is 0 or 1, the second element
## is a single reference to the target item. If the first element is 2, there
## will be one or more references to scalars (or references to references if
## the element in the slice is itself a hash or array reference).
## This routine is called at runtime.
##==============================================================================
sub alias {
	my $left = shift;
	my $cx = PadWalker::_upcontext(1);
	my $cv = $cx ? _context_cv($cx) : 0;
	my ($rtype, $rpos, @rrefs);

	foreach (@$left) {
		##----------------------------------------------------------------------
		## Create an alias to the next element on the right side if this item
		## is defined.
		##----------------------------------------------------------------------
		if (defined $_) {
			my ($flattened, $varname, $varref) = @$_;

t/advanced.t  view on Meta::CPAN

			'option1' => {
				'seven' => 7,
				'eight' => 8,
				'nine' => 9,
			},
		},
	},
);

if ($] >= 5.008) {
	skip("skip | Due to a problem in PadWalker", 1);
	skip("skip | with Perl 5.8.x,", 1);
	skip("skip | aliases at the root level of the program", 1);
	skip("skip | don't function.", 1);
	skip("skip | Aliases in subroutines and methods, however,", 1);
	skip("skip | continue to function.", 1);
	skip("skip | We apologize for the inconvenience.", 1);
	skip("skip | Sincerely,", 1);
	skip("skip | The Management", 1);
} else {
	my %hash := %{$sample{'three'}->{'six'}->{'option1'}};

t/basic.t  view on Meta::CPAN

my $t = new test_hash_methods;

$t->test(
	'four',
	[ 'five', 'six' ],
	{ 'seven' => 7, 'eight' => 8 },
	0
);

if ($] >= 5.008) {
	skip("skip | Due to a problem in PadWalker in 5.8.x,", 1);
	skip("skip | aliases can't be created at the root level.", 1);
	skip("skip | However, aliases in subroutines still work.", 1);
	skip("skip | We apologize for the inconvenience.", 1);
} else {
	my $scalar1 = [ qw/one two three/ ];
	my @array := @$scalar1;
	
	ok($array[0] eq 'one' && $array[1] eq 'two' && $array[2] eq 'three');
	my $scalar2 = { 'one' => 1, 'two' => 2, 'three' => 3 };
	my %hash := %$scalar2;



( run in 0.670 second using v1.01-cache-2.11-cpan-05444aca049 )