Luke Palmer <[EMAIL PROTECTED]> writes:
> Hmm, since we're requiring no whitespace between a variable and it's
> subscript, this should be possible:
>
> if "Dough" [eqn 4] "Douglas" {...}
Lisp! :-)
Well, almost. Now this would be lisp-y:
if $test [$moon.is_waxing ? &infix:< : &infix:>=] $target {...}
Let us see ... somewhat speculative and probably short-of-the-mark
generalization coming up:
macro infix:[ ($lhs, $op, $rhs)
is parsed(/(<Perl6.expr>) \] (<Perl6.expr>)/) {
return {
$op($lhs, $rhs)
};
}
(Precedence? Err ... the left hand side has already been parsed,
so infix:[ must be of fixed precedence to the left hand side, right?
Damn, I thought I had it ...)
Then vector operators, like >>+<<, are "really" just simple
[vectorize &infix:+] and similar -- except properly optimized and
presumably with proper precedence. And, you can write:
if "Dough" [&String::strncmp.assuming(n => 4)] "Douglas" {...}
Still long. Oh well. infix:[eqn, perhaps? At least that one will
be of fixed precedence. Right?
macro infix:[eqn ($lhs, $n, $rhs)
is equiv(&infix:eq)
is parsed(/(<Perl6.expr>)
\]
(<Perl6.expr but speculatively_equiv(&infix:eq)>)/) {
return {
String::strncmp($lhs, $rhs, n => $n)
};
}
Eirik
--
"So this is the Sword of Immortality? Huh?
What's it doin' in a CRYPT?!"
--- John S. Novak, III, quoting an unnamed player