[perl #124979]

--001a1146944cbdf287055f691ecb
Content-Type: text/plain; charset="UTF-8"

This is not limited in operator overloading

```
my $a;
$a := { $^a + $^b }
# ok
```

```
my &a;
&a := { $^a + $^b }
# Cannot use bind operator with this left-hand side
```

```
my &a := { $^a + $^b }
say a(1, 2)
# 3
```

```
my &infix:<plus> := { $^a + $^b };

say 1 plus 2 plus 3

# 6
```


Note that it is all well if use `=` instead of `:=`

```
{
  my &infix:<plus>;
  BEGIN {
    &infix:<plus> = { $^a + $^b };
  }

  is 3 plus 5, 8, 'overloading an operator using "my &infix:<...>" worked';
}
# ok 1 - overloading an operator using "my &infix:<...>" worked
```

This test is moved to S06-operator-overloading/infix.t, BTW

--001a1146944cbdf287055f691ecb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e,monospace;font-size:large">This is not limited in operator overloading<br=
></div><div class=3D"gmail_default" style=3D"font-family:monospace,monospac=
e;font-size:large"><br></div><div class=3D"gmail_default" style=3D"font-fam=
ily:monospace,monospace;font-size:large">```</div><div class=3D"gmail_defau=
lt" style=3D"font-family:monospace,monospace;font-size:large">my $a;</div><=
div class=3D"gmail_default" style=3D"font-family:monospace,monospace;font-s=
ize:large">$a :=3D { $^a + $^b }</div><div class=3D"gmail_default" style=3D=
"font-family:monospace,monospace;font-size:large"># ok</div><div class=3D"g=
mail_default" style=3D"font-family:monospace,monospace;font-size:large">```=
</div><div class=3D"gmail_default" style=3D"font-family:monospace,monospace=
;font-size:large"><br></div><div class=3D"gmail_default"><div class=3D"gmai=
l_default" style=3D"font-family:monospace,monospace;font-size:large">```</d=
iv><div class=3D"gmail_default" style=3D"font-family:monospace,monospace;fo=
nt-size:large">my &amp;a;</div><div class=3D"gmail_default" style=3D"font-f=
amily:monospace,monospace;font-size:large">&amp;a :=3D { $^a + $^b }</div><=
div class=3D"gmail_default" style=3D"font-family:monospace,monospace;font-s=
ize:large">#=C2=A0<span style=3D"font-variant-ligatures:no-common-ligatures=
;background-color:rgba(0,0,0,0.8);color:rgb(40,254,20);font-family:&quot;So=
urce Code Pro&quot;;font-size:16px">Cannot use bind operator with this left=
-hand side</span></div>







<div class=3D"gmail_default" style=3D"font-family:monospace,monospace;font-=
size:large">```</div><div class=3D"gmail_default" style=3D"font-family:mono=
space,monospace;font-size:large"><br></div><div class=3D"gmail_default" sty=
le=3D"font-family:monospace,monospace;font-size:large">```</div><div class=
=3D"gmail_default" style=3D"font-family:monospace,monospace;font-size:large=
">my &amp;a :=3D { $^a + $^b }</div><div class=3D"gmail_default" style=3D"f=
ont-family:monospace,monospace;font-size:large">say a(1, 2)</div><div class=
=3D"gmail_default" style=3D"font-family:monospace,monospace;font-size:large=
"># 3</div><div class=3D"gmail_default" style=3D"font-family:monospace,mono=
space;font-size:large">```</div><div class=3D"gmail_default" style=3D"font-=
family:monospace,monospace;font-size:large"><br></div><div class=3D"gmail_d=
efault" style=3D"font-family:monospace,monospace;font-size:large">```</div>=
<div class=3D"gmail_default"><div class=3D"gmail_default"><div class=3D"gma=
il_default"><font face=3D"monospace, monospace" size=3D"4">my &amp;infix:&l=
t;plus&gt; :=3D { $^a + $^b };</font></div><div class=3D"gmail_default"><fo=
nt face=3D"monospace, monospace" size=3D"4"><br></font></div><div class=3D"=
gmail_default"><font face=3D"monospace, monospace" size=3D"4">say 1 plus 2 =
plus 3</font></div><div class=3D"gmail_default"><font face=3D"monospace, mo=
nospace" size=3D"4"><br></font></div><div class=3D"gmail_default"><font fac=
e=3D"monospace, monospace" size=3D"4"># 6</font></div></div></div><div clas=
s=3D"gmail_default" style=3D"font-family:monospace,monospace;font-size:larg=
e">```</div><div class=3D"gmail_default" style=3D"font-family:monospace,mon=
ospace;font-size:large"><br></div><div class=3D"gmail_default" style=3D"fon=
t-family:monospace,monospace;font-size:large"><br></div><div class=3D"gmail=
_default" style=3D"font-family:monospace,monospace;font-size:large">Note th=
at it is all well if use `=3D` instead of `:=3D`</div><div class=3D"gmail_d=
efault" style=3D"font-family:monospace,monospace;font-size:large"><br></div=
><div class=3D"gmail_default" style=3D"font-family:monospace,monospace;font=
-size:large">```</div><div class=3D"gmail_default"><div class=3D"gmail_defa=
ult"><div class=3D"gmail_default"><font face=3D"monospace, monospace" size=
=3D"4">{</font></div><div class=3D"gmail_default"><font face=3D"monospace, =
monospace" size=3D"4">=C2=A0 my &amp;infix:&lt;plus&gt;;</font></div><div c=
lass=3D"gmail_default"><font face=3D"monospace, monospace" size=3D"4">=C2=
=A0 BEGIN {</font></div><div class=3D"gmail_default"><font face=3D"monospac=
e, monospace" size=3D"4">=C2=A0 =C2=A0 &amp;infix:&lt;plus&gt; =3D { $^a + =
$^b };</font></div><div class=3D"gmail_default"><font face=3D"monospace, mo=
nospace" size=3D"4">=C2=A0 }</font></div><div class=3D"gmail_default"><font=
 face=3D"monospace, monospace" size=3D"4"><br></font></div><div class=3D"gm=
ail_default"><font face=3D"monospace, monospace" size=3D"4">=C2=A0 is 3 plu=
s 5, 8, &#39;overloading an operator using &quot;my &amp;infix:&lt;...&gt;&=
quot; worked&#39;;</font></div><div class=3D"gmail_default"><font face=3D"m=
onospace, monospace" size=3D"4">}</font></div><div class=3D"gmail_default">=
<font face=3D"monospace, monospace" size=3D"4">#=C2=A0</font><span style=3D=
"font-variant-ligatures:no-common-ligatures;background-color:rgba(0,0,0,0.8=
);color:rgb(40,254,20);font-family:&quot;Source Code Pro&quot;;font-size:16=
px">ok 1 - overloading an operator using &quot;my &amp;infix:&lt;...&gt;&qu=
ot; worked</span></div>







</div></div><div class=3D"gmail_default" style=3D"font-family:monospace,mon=
ospace;font-size:large">```</div><div class=3D"gmail_default" style=3D"font=
-family:monospace,monospace;font-size:large"><br></div><div class=3D"gmail_=
default" style=3D"font-family:monospace,monospace;font-size:large">This tes=
t is moved to S06-operator-overloading/infix.t, BTW</div></div></div>

--001a1146944cbdf287055f691ecb--
0
wander4096
12/3/2017 5:45:55 AM
perl.perl6.compiler 1196 articles. 0 followers. Follow

0 Replies
0 Views

Similar Articles

[PageSpeed] 6

Reply: