opPow, opDollar

Walter Bright newshound1 at digitalmars.com
Sat Nov 7 10:27:37 PST 2009


KennyTM~ wrote:
> Nice. Meanwhile, I'd like an opSum() operator (∑ range) as well. It's 
> primarily about syntax sugar: reduce!("a+b")(range) is so ugly. In 
> practice, the most important case is the sum from 1 to n, which is an 
> extremely common operation. reduce!("a+b")(iota(1,n+1)) is horribly ugly 
> for something so fundamental. It's so ugly that noone uses it: you 
> always change it to n*(n+1)/2. But then, n gets evaluated twice.

As amply illustrated, one can make this argument pro and con about any 
builtin operator. The waterfront real estate of builtin operators is 
extremely limited, so we need to be very parsimonious in allocating it. 
Candidates for builtin operators need to have a very high bar.

The question is, does ^^ clear that bar or not?



More information about the Digitalmars-d mailing list