On Tuesday, 6 February 2018 at 02:14:35 UTC, Meta wrote:
It's already possible, with only very slightly worse aesthetics:struct VecOp(T) { T[] arr; pragma(inline, true) T[] opOpAssign(string op: "+", Range)(Range r) { int i; foreach (e; r) { arr[i] += e; i++; } return arr; } } pragma(inline, true) VecOp!E vecOp(E)(return E[] arr) { return typeof(return)(arr); }
I'm not sure if this is equivalent to what I asked, but in the event it is, here is a thought.
A fully featured VecOp could be part of druntime, and slices as array ops operands could be replaced by slice.vecOp by the compiler.
If this vectorize well, this allow to remove array ops from the language. (However it seems to me array ops are recognized at the operator level but well)
