Skip to content

Commit

Permalink
Remove ngrep, nmap and nfor.
Browse files Browse the repository at this point in the history
They're special case syntax dead ends.  @Array->foreach( def($x,$y,$z) {} ); and @Array->map
handle the same problem with a general syntax.
  • Loading branch information
schwern committed Jul 22, 2010
1 parent 747ef9a commit 6f174ff
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 125 deletions.
1 change: 0 additions & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ my $builder = MyBuild->new(
'Digest::SHA1' => '2.09',
'Digest::MD5' => '2.36',
'Object::ID' => '0.1.0',
'Block::NamedVar' => '0.006',
"Devel::Declare::MethodInstaller::Simple" => '0.006000',
},
build_requires => {
Expand Down
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.3.0_03
Removed Features
* Remove ngrep, nmap and nfor. Replaced by @array->foreach( def($x,$y) ) {}
and @array->map( def($x) {} );


2.3.0_02 Thu Jul 15 19:13:22 PDT 2010
New Features
* Signature introspection, via $code->signature, for subroutines defined
Expand Down
46 changes: 0 additions & 46 deletions lib/perl5i.pm
Original file line number Diff line number Diff line change
Expand Up @@ -931,52 +931,6 @@ of $@ and a nice syntax layer:
See perldoc L<Try::Tiny> for details.
=head2 Block::NamedVar
L<Block::NamedVar> provides the 'ngrep', 'nmap', and 'nfor' keywords. These act
like 'grep', 'map', and 'for', The difference is that you specify the names of
the block variables. In the case of 'nfor' you can iterate over chunks of your
list at a time.
=head3 ngrep
# grep with lexical $x.
@list = ngrep my $x { $x =~ m/^[a-zA-Z]$/ } @stuff;
# grep with package variable $v
@list = ngrep our $v { $v =~ m/^[a-zA-Z]$/ } @stuff;
# grep with closure over existing $y
my $y;
@list = ngrep $y { $y =~ m/^[a-zA-Z]$/ } @stuff;
=head3 nmap
Behaves just like ngrep with lexical, package, or closure variables.
# map with lexical $x
@list = nmap my $x { "updated_$x" } @stuff;
=head3 nfor
Works like for, you can even use 'last' and 'next'.
# Iterate a hash taking key and value each pass:
nfor my ( $key, $value ) ( %a_hash ) {
next if $key eq "_hidden";
print $key, " = ", $value, "\n";
last if ...;
}
# Defaults to $a and $b:
nfor ( %a_hash ) {
print $a, " = ", $b, "\n";
}
# Iterate over 3 or more elements of the list per pass:
nfor my ( $x, $y, $z ) ( qw/a b c d e f/ ) {
# Will be run twice.
}
=head2 Better load errors
Expand Down
2 changes: 1 addition & 1 deletion lib/perl5i/2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sub import {
["CLASS"], ["File::chdir"],
[English => qw(-no_match_vars)],
["Want" => qw(want)], ["Try::Tiny"], ["Perl6::Caller"], ["Carp"],
['Block::NamedVar'], ['perl5i::2::Signatures'],
['perl5i::2::Signatures'],
['Child' => qw(child)],
) );

Expand Down
77 changes: 0 additions & 77 deletions t/namedvar.t

This file was deleted.

0 comments on commit 6f174ff

Please sign in to comment.