3 ms·
All the examples where they're useful are contrived. And simplicity is an actual goal of computer language design.
by Retra 11y ago
All the examples where they're useful are contrived.
And simplicity is an actual goal of computer language design.
- mattst88 11y agoThat's quite a claim. I agree that most uses of these operators as an expression are not wise. Some are though. As a counter-claim, I offer: array[i++] = this; array[i++] = that; array[i++] = the_other; which also extends nicely when some of those elements are optional.
- SamReidHughes 11y agoFor what it's worth, you could always make a function postincr and write array[postincr(&i)] = ...; if you're doing enough of those that it's worth it.
- lomnakkus 11y agoI presume you're using C as the example language? Most modern languages have an append-to-list method/function, so your example isn't really applicable in those langauges. For example, ArrayList#add() for Java or Vec::push[1] for Rust, etc. (Yes, these are technically dynamically sized arrays, but you can always reserve the necessary amount of space up front if you so desire.) [1] https://doc.rust-lang.org/std/vec/struct.Vec.html#method.push https://doc.rust-lang.org/std/vec/struct.Vec.html#method.pus...