On 5/6/05, Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> wrote:
> I find this table very interesting, in that it shows the fundamental
> difference between reduce and the existing meta-ops.

Yep, that was basically the whole point of the table.

> The existing meta-operators alter the semantics of the opoerator, but
> don't really change its syntax; a unary operator is still unary, a
> binary operator is still binary, and so on.  Reduce is irreducibly
> (pardon the pun) different, in that it alters the syntax as well as
> the semantics.

I was thinking of restricting the ways in which meta-ops can alter the
syntax of an op, but now I think we're better off not letting it
happen at all. Meta-ops that redefine syntax would be very hairy for
the compiler (as I pointed out), and probably wouldn't buy us much
that you couldn't achieve with a macro anyway.

> That would result in the following syntaxes:
> 
>     reduce { $^a / $^b } @foo;
>     reduce [/] @foo;
> 
>    $sum = reduce[+] @array;
>    $fact = reduce[*] 1..$num;
>    $firsttrue = reduce[||] @args;
>    $firstdef = reduce[//] @args;
>    @sumrows := reduce[+«] @rows;
>    @foo[0..9; reduce[;](@dims); 0..9]

I personally like that, and it has the additional property of avoiding
the "[+] @foo" vs. "[+1, -2]" ambiguity I pointed out.

Furthermore, it makes it /much/ easier for newbies to figure out what
that code actually does (since they can just grep for 'reduce' in the
docs).


Stuart

Reply via email to