sub infix:foo ($a, $b = ($a foo 2 * 3 - $a)) is tighter(infix:*)
{
$a == 0 ?? 1 foo 2 * 3 !! $a + $b
}
say 1 foo (2 * 3);
# 7
say (1 foo 2) * 3;
# 9
say 1 foo 2 * 3;
# 9
say infix:foo(1);
# Niecza: 7
say 0 foo 0;
# Niecza: 9
The way that Niecza does this is to install the operator
On Fri, Dec 23, 2011 at 10:59:58PM +1100, Kris Shannon wrote:
sub infix:foo ($a, $b = ($a foo 2 * 3 - $a)) is tighter(infix:*)
{
$a == 0 ?? 1 foo 2 * 3 !! $a + $b
}
say 1 foo (2 * 3);
# 7
say (1 foo 2) * 3;
# 9
say 1 foo 2 * 3;
# 9
say infix:foo(1);
# Niecza: 7
say 0 foo
Branch: refs/heads/master
Home: https://github.com/perl6/specs
Commit: e52fc11b61767329480e0aee8df62060c020494c
https://github.com/perl6/specs/commit/e52fc11b61767329480e0aee8df62060c020494c
Author: Bruce Gray bruce.g...@acm.org
Date: 2011-12-23 (Fri, 23 Dec 2011)
Changed