Re: Another adverb on operator question

2008-08-07 Thread Jon Lang
Perhaps I'm missing something; but why couldn't you say '[lt]:lc $a, $b, $c'?

That is, I see the "reducing meta-operator" as a way of taking a
list-associative infix operator and treating it as a function call,
albeit one with a funny name.  As such, you should be able to do
things with a reduced operator in the same way that you could with any
function that has a signature of ([EMAIL PROTECTED], *%adverb).  Am I wrong?

-- 
Jonathan "Dataweaver" Lang


Re: Another adverb on operator question

2008-08-07 Thread Larry Wall
On Thu, Aug 07, 2008 at 05:04:41AM -0500, John M. Dlugosz wrote:
> What about adverbs on reduction operators?
>
>   [lt :lc] $a,$b,$c  # all in decreasing order

I don't think that'll fly because reduce operators are parsed as single
tokens to disambiguate them from array composers, and there are already
7000 reduce operators.  Currently every basic infix operator adds 88
different possible reduce operators.  (We could cut that down somewhat
if we removed Texas quotes from the language.)  But adding in all
possible adverbs will just completely blow the lexer out of the water.

Or to put it another way, how should we parse something like your
example after someone adds "sub lt" without resorting to arbitrarily
complex backtracking?

The only other way I see to distinguish is to require all array
composers to contain a space, since reduce operators may not.  But I
think that's kinda tacky, and your example still would not work unless
you changed it to [lt:lc].

There comes a point at which it's just better to force the user to say:

my &infix: ::= &infix:.assuming(:lc);


[lt_lc] $a, $b, $c;

Larry