Skip to content

Commit

Permalink
Allow operators like infix:<..> to autocurry when passed a WhateverCo…
Browse files Browse the repository at this point in the history
…de argument.
  • Loading branch information
colomon committed Nov 18, 2010
1 parent 019c864 commit 32c08e3
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/Perl6/Actions.pm
Expand Up @@ -3516,27 +3516,33 @@ sub capture_or_parcel($args, $name) {
# to curry for now; in the future, we will inspect the multi signatures
# of the op to decide, or likely store things in this hash from that
# introspection and keep it as a quick cache.

# not_curried = 1 means do not curry Whatever, but do curry WhateverCode
# not_curried = 2 means do not curry either.

our %not_curried;
INIT {
%not_curried{'&infix:<...>'} := 1;
%not_curried{'&infix:<..>'} := 1;
%not_curried{'&infix:<..^>'} := 1;
%not_curried{'&infix:<^..>'} := 1;
%not_curried{'&infix:<^..^>'} := 1;
%not_curried{'&prefix:<^>'} := 1;
%not_curried{'&prefix:<^>'} := 2;
%not_curried{'&infix:<xx>'} := 1;
%not_curried{'&infix:<~~>'} := 1;
%not_curried{'&infix:<=>'} := 1;
%not_curried{'&infix:<:=>'} := 1;
%not_curried{'WHAT'} := 1;
%not_curried{'HOW'} := 1;
%not_curried{'WHO'} := 1;
%not_curried{'WHERE'} := 1;
%not_curried{'&infix:<~~>'} := 2;
%not_curried{'&infix:<=>'} := 2;
%not_curried{'&infix:<:=>'} := 2;
%not_curried{'WHAT'} := 2;
%not_curried{'HOW'} := 2;
%not_curried{'WHO'} := 2;
%not_curried{'WHERE'} := 2;
}
sub whatever_curry($/, $past, $upto_arity) {
if $past.isa(PAST::Op) && !%not_curried{$past.name} && $past<pasttype> ne 'call' {
if ($upto_arity >= 1 && ($past[0].returns eq 'Whatever' || $past[0].returns eq 'WhateverCode'))
|| ($upto_arity == 2 && ($past[1].returns eq 'Whatever' || $past[1].returns eq 'WhateverCode')) {
if $past.isa(PAST::Op) && %not_curried{$past.name} != 2 && $past<pasttype> ne 'call' {
if ($upto_arity >= 1 && (($past[0].returns eq 'Whatever' && !%not_curried{$past.name})
|| $past[0].returns eq 'WhateverCode'))
|| ($upto_arity == 2 && (($past[1].returns eq 'Whatever' && !%not_curried{$past.name})
|| $past[1].returns eq 'WhateverCode')) {

my $counter := 0;
my $sig := Perl6::Compiler::Signature.new();
Expand Down

0 comments on commit 32c08e3

Please sign in to comment.