Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
for's impl is now .FOR, remaining .for can be .map
  • Loading branch information
TimToady committed Apr 28, 2015
1 parent 4b39cd5 commit 71ff418
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/Perl6/Actions.nqp
Expand Up @@ -255,7 +255,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
# Turn $code into "for lines() { $code }"
sub wrap_option_n_code($/, $code) {
$code := make_topic_block_ref($/, $code, copy => 1);
my $past := QAST::Op.new(:op<callmethod>, :name<for>,
my $past := QAST::Op.new(:op<callmethod>, :name<FOR>,
QAST::Op.new(:op<call>, :name<&lines>),
QAST::Op.new(:op<p6capturelex>, $code)
);
Expand Down Expand Up @@ -841,7 +841,7 @@ Compilation unit '$file' contained the following violations:
$past := make_topic_block_ref($/, $past, migrate_stmt_id => $*STATEMENT_ID);
}
$past := QAST::Op.new(
:op<callmethod>, :name<for>, :node($/),
:op<callmethod>, :name<FOR>, :node($/),
QAST::Op.new(:op('call'), :name('&infix:<,>'), $cond),
block_closure($past)
);
Expand Down Expand Up @@ -1170,7 +1170,7 @@ Compilation unit '$file' contained the following violations:
method statement_control:sym<for>($/) {
my $xblock := $<xblock>.ast;
my $past := QAST::Op.new(
:op<callmethod>, :name<for>, :node($/),
:op<callmethod>, :name<FOR>, :node($/),
QAST::Op.new(:name('&infix:<,>'), :op('call'), $xblock[0]),
block_closure($xblock[1])
);
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Optimizer.nqp
Expand Up @@ -1027,7 +1027,7 @@ class Perl6::Optimizer {
# If it's a for 1..1000000 { } we can simplify it to a while loop. We
# check this here, before the tree is transformed by call inline opts.
if $optype eq 'callmethod' && $op.name eq 'sink' &&
nqp::istype($op[0], QAST::Op) && $op[0].op eq 'callmethod' && $op[0].name eq 'for' && @($op[0]) == 2 &&
nqp::istype($op[0], QAST::Op) && $op[0].op eq 'callmethod' && $op[0].name eq 'FOR' && @($op[0]) == 2 &&
nqp::istype((my $c1 := $op[0][0]), QAST::Op) && $c1.name eq '&infix:<,>' &&
(nqp::istype((my $c2 := $op[0][0][0]), QAST::Op) &&
nqp::existskey(%range_bounds, $c2.name)
Expand Down
6 changes: 3 additions & 3 deletions src/core/Any.pm
Expand Up @@ -179,9 +179,9 @@ my class Any { # declared in BOOTSTRAP
multi method map($block, :$label) is rw {
MapIter.new(self, $block, Bool::False, :$label).list
}
proto method for (|) { * }
multi method for(Whatever) is rw { self }
multi method for($block, :$label) is rw {
proto method FOR (|) { * }
multi method FOR(Whatever) is rw { self }
multi method FOR($block, :$label) is rw {
MapIter.new(self, $block, Bool::False, :$label).list;
}
proto method flatmap (|) { * }
Expand Down
4 changes: 2 additions & 2 deletions src/core/Exception.pm
Expand Up @@ -657,7 +657,7 @@ my class X::Undeclared::Symbols does X::Comp {
}
method message(X::Undeclared::Symbols:D:) {
sub l(@l) {
my @lu = @l.for({ nqp::hllize($_) }).unique.sort;
my @lu = @l.map({ nqp::hllize($_) }).unique.sort;
'used at line' ~ (@lu == 1 ?? ' ' !! 's ') ~ @lu.join(', ')
}
sub s(@s) {
Expand Down Expand Up @@ -1700,7 +1700,7 @@ my class X::Multi::Ambiguous is Exception {
method message {
join "\n",
"Ambiguous call to '$.dispatcher.name()'; these signatures all match:",
@.ambiguous.for(*.signature.perl)
@.ambiguous.map(*.signature.perl)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/List.pm
Expand Up @@ -474,7 +474,7 @@ my class List does Positional { # declared in BOOTSTRAP
# if $by.arity < 2, then we apply the block to the elements
# for sorting.
if ($by.?count // 2) < 2 {
my $list = self.for($by).eager;
my $list = self.map($by).eager;
nqp::p6sort($index_rpa, -> $a, $b { $list.AT-POS($a) cmp $list.AT-POS($b) || $a <=> $b });
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/core/LoL.pm
Expand Up @@ -183,7 +183,7 @@ sub infix:<Z>(|lol) {

gather {
loop {
my \p = @l.for: { last unless .gimme(1); .shift }
my \p = @l.map: { last unless .gimme(1); .shift }
last if p.elems < $arity;
take-rw p.Parcel;
}
Expand All @@ -193,10 +193,10 @@ sub infix:<Z>(|lol) {
my &zip := &infix:<Z>;

sub roundrobin(**@lol) {
my @l = @lol.for({ (.flat,).list.item });
my @l = @lol.map({ (.flat,).list.item });
gather {
my $p;
while $p := @l.grep(*.Bool).for(*.shift).eager.Parcel {
while $p := @l.grep(*.Bool).map(*.shift).eager.Parcel {
take $p;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Main.pm
Expand Up @@ -101,7 +101,7 @@ my sub MAIN_HELPER($retval = 0) is hidden-from-backtrace {
}
}
else {
my $constraints = $param.constraint_list.for(*.gist).join(' ');
my $constraints = $param.constraint_list.map(*.gist).join(' ');
my $simple-const = $constraints && $constraints !~~ /^_block/;
$argument = $param.name ?? '<' ~ substr($param.name,1) ~ '>' !!
$simple-const ?? $constraints !!
Expand Down
2 changes: 1 addition & 1 deletion src/core/Parcel.pm
Expand Up @@ -75,7 +75,7 @@ my class Parcel does Positional { # declared in BOOTSTRAP
method list() { nqp::p6list(nqp::clone($!storage), List, Mu) }
method lol() { nqp::p6list(nqp::clone($!storage), LoL, Mu) }
method eager() { nqp::p6list(nqp::clone($!storage), List, Mu).eager }
method for(|c) {
method FOR(|c) {
if nqp::elems($!storage) == 1 and !nqp::isnull(nqp::atpos($!storage,0)) and !nqp::iscont(nqp::atpos($!storage,0)) {
try { nqp::atpos($!storage,0).map(|c) } // nqp::p6list(nqp::clone($!storage), List, Mu).map(|c);
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/Str.pm
Expand Up @@ -541,7 +541,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
$x = (1..$limit) unless nqp::istype($limit, Whatever) || $limit == Inf;
$match
?? self.match(:g, :$x, $pat)
!! self.match(:g, :$x, $pat).for: { .Str }
!! self.match(:g, :$x, $pat).map: { .Str }
}

method match($pat,
Expand Down Expand Up @@ -1330,7 +1330,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
my sub expand($s) {
return $s.list
if nqp::istype($s,Iterable) || nqp::istype($s,Positional);
$s.comb(/ (\w) '..' (\w) | . /, :match).for: {
$s.comb(/ (\w) '..' (\w) | . /, :match).map: {
.[0] ?? ~.[0] .. ~.[1] !! ~$_
};
}
Expand Down Expand Up @@ -1382,7 +1382,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
# Positive indent does indent
multi method indent(Int() $steps where { $_ > 0 }) {
# We want to keep trailing \n so we have to .comb explicitly instead of .lines
return self.comb(/:r ^^ \N* \n?/).for({
return self.comb(/:r ^^ \N* \n?/).map({
given $_.Str {
when /^ \n? $ / {
$_;
Expand Down Expand Up @@ -1418,14 +1418,14 @@ my class Str does Stringy { # declared in BOOTSTRAP

sub outdent($obj, $steps) {
# Loop through all lines to get as much info out of them as possible
my @lines = $obj.comb(/:r ^^ \N* \n?/).for({
my @lines = $obj.comb(/:r ^^ \N* \n?/).map({
# Split the line into indent and content
my ($indent, $rest) = @($_ ~~ /^(\h*) (.*)$/);

# Split the indent into characters and annotate them
# with their visual size
my $indent-size = 0;
my @indent-chars = $indent.comb.for(-> $char {
my @indent-chars = $indent.comb.map(-> $char {
my $width = $char eq "\t"
?? $?TABSTOP - ($indent-size mod $?TABSTOP)
!! 1;
Expand All @@ -1437,7 +1437,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
});

# Figure out the amount * should outdent by, we also use this for warnings
my $common-prefix = min @lines.grep({ .<indent-size> || .<rest> ~~ /\S/}).for({ $_<indent-size> });
my $common-prefix = min @lines.grep({ .<indent-size> || .<rest> ~~ /\S/}).map({ $_<indent-size> });
return $obj if $common-prefix === Inf;

# Set the actual outdent amount here
Expand Down Expand Up @@ -1706,7 +1706,7 @@ sub UNBASE_BRACKET($base, @a) is hidden-from-backtrace {
}

sub chrs(*@c) returns Str:D {
@c.for({.chr}).join;
@c.map({.chr}).join;
}

sub SUBSTR-START-OOR(\from,\max) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/asyncops.pm
Expand Up @@ -8,7 +8,7 @@ multi sub await(Promise:D $p) {
$p.result
}
multi sub await(*@awaitables) {
@awaitables.eager.for(&await)
@awaitables.eager.map(&await)
}
multi sub await(Channel:D $c) {
$c.receive
Expand Down
4 changes: 2 additions & 2 deletions src/core/metaops.pm
Expand Up @@ -88,7 +88,7 @@ sub METAOP_ZIP(\op, &reduce) {
}
gather {
loop {
my \z = @lol.for: { last unless .gimme(1); .shift }
my \z = @lol.map: { last unless .gimme(1); .shift }
last if z.elems < $arity;
take-rw $rop(|z);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ sub METAOP_REDUCE_LISTINFIX(\op, :$triangle) {
}
}, :infinite(p.infinite))
}
!! sub (|values) { my \p = values[0]; nqp::iscont(p[0]) ?? op.(|p.for({nqp::decont($_).list.Parcel})) !! op.(|p) }
!! sub (|values) { my \p = values[0]; nqp::iscont(p[0]) ?? op.(|p.map({nqp::decont($_).list.Parcel})) !! op.(|p) }
}


Expand Down

0 comments on commit 71ff418

Please sign in to comment.