Skip to content

Commit

Permalink
allow ~~ to chain where practical
Browse files Browse the repository at this point in the history
(A regex or closure must be at the end of the chain, however.)
  • Loading branch information
TimToady committed Dec 10, 2015
1 parent 06ed575 commit f457007
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Perl6/Actions.nqp
Expand Up @@ -5890,6 +5890,14 @@ Compilation unit '$file' contained the following violations:
# autoprime only on Whatever with explicit *
return 0 if $lhs ~~ QAST::WVal && istype($lhs.returns, $*W.find_symbol(['Whatever'])) && nqp::isconcrete($lhs.value);
return 0 if $rhs ~~ QAST::WVal && istype($rhs.returns, $*W.find_symbol(['Whatever'])) && nqp::isconcrete($rhs.value);

# don't need topicalization, so allow chaining?
return 0 if !$*COMPILING_CORE_SETTING && (
$rhs.has_compile_time_value ||
nqp::istype($rhs,QAST::Var) ||
nqp::istype($lhs,QAST::Op) && $lhs.op eq 'chain'
);

my $old_topic_var := $lhs.unique('old_topic');
my $result_var := $lhs.unique('sm_result');
my $sm_call;
Expand Down
5 changes: 5 additions & 0 deletions src/core/Mu.pm
Expand Up @@ -702,6 +702,11 @@ multi sub infix:<~~>(Mu \topic, Mu \matcher) {
matcher.ACCEPTS(topic).Bool;
}

proto sub infix:<!~~>(Mu \topic, Mu \matcher) { * }
multi sub infix:<!~~>(Mu \topic, Mu \matcher) {
matcher.ACCEPTS(topic).not;
}

proto sub infix:<=:=>(Mu $?, Mu $?) is pure { * }
multi sub infix:<=:=>($?) { Bool::True }
multi sub infix:<=:=>(Mu \a, Mu \b) {
Expand Down

0 comments on commit f457007

Please sign in to comment.