dlang.org
dlang.org copied to clipboard
Clarify spec for "+=" and friends
See https://forum.dlang.org/post/[email protected]
(submitted through the website and I cannot make changes to this PR. Because I am cleaning up after people, if you don't like it, please submit your own PR.)
submitted through the website and I cannot make changes to this PR.
Is you "you don't want to" or you technically can't? Editing a PR made from the website is easy: If you don't have the repo locally, clone it:
git clone [email protected]/JohanEngelen/dlang.org
or if you already have it, update its remote info:
git fetch
and then go into the usual flow:
git checkout patch-5
// make changes & commit
git push -f
This needs to be extended with semantics for operations on arrays, like ~=
(for which the types of lhs and rhs are not the same, T[]
vs T
).
int work(ref int[] array) {
array ~= 5;
return 0;
}
void doTildeAssignment(T)(ref T[] x, T y) {
x = x ~ y;
}
void main(){
int[] array;
version(none) {
array ~= work(array);
} else {
doTildeAssignment(array, work(array));
}
assert(array == [5,0]);
}
See https://github.com/ldc-developers/ldc/issues/2588