DIP58: ".." as a Binary Operator
Chris Williams
yoreanon-chrisw at yahoo.co.jp
Mon Mar 17 13:32:53 PDT 2014
On Monday, 17 March 2014 at 20:13:20 UTC, Mason McGill wrote:
> Interesting, though I feel like operator syntax really shines
> when either
> 1) It's significantly shorter/simpler than the equivalent
> function calls.
> 2) It appeals to domain-specific intuitions.
In general, I agree. Though I think that my examples suffer from
being poor examples and for allowing the most complete
overridability (short of using lambdas). The .. operator could be
written to only accept a constant step, like:
a ..!5 b;
The place where I was thinking that templating normal operators
might be handy is actually in games, where you might want to (for
example) treat a 4x4 matrix in the input as a 4x3 matrix during
multiplication.
a *!M43 b;
Again, by restricting the allowed template parameters, rather
than exposing code, you do end up with a shorter syntax, than a
function call.
More information about the Digitalmars-d
mailing list