So I sit here and think for a minute about how nice it will be in P6 to
be able to define
operator infix:eqi($str1, $str2) {...}
for doing
if ($1 eqi "last")
and I think about the whole 'C' string library. Which dredges up my old
questions about parameterized operators:
How can I conveniently pass an extra parameter to a historically binary
operator?
At one point, the colon was going to do that, but Larry took it back:
if ("Dough" eqn:4 "Douglas") # true
{ ...
The options left seem to be:
package String;
sub strncmp($a, $b, $n) {...}
package main;
sub infix:immed &String::strncmp.assuming($n = 4);
if ("Dough" immed "Douglas") # ?
or:
class InfixBinary is Code {...}
# How do I create a "type"? -- I want to define a return-type-spec
# that just guarantees context behavior.
sub eqn($max) returns InfixBinary {
return &String::strncmp.assuming($n=$max);
}
if ("Dough" eqn(4) "Douglas") ...
Frankly, I like the second one.
=Austin