3 ms·
`this` and `that` are arrows which range over a stream of data; `=` is copy, and `++` moves the arrow along the stream. This isn't a "clever one-liner" it is a
by mjburgess 4y ago
`this` and `that` are arrows which range over a stream of data; `=` is copy, and `++` moves the arrow along the stream.
This isn't a "clever one-liner" it is a clear and precise syntax for expressing the operation the machine actually performs.
while(copy(current(stream_a), current(stream_b)) and not end_of_stream(stream_a))
You might prefer the above, but then, that's every other major language. The beauty of C is that the above code has to compile to something like the C version. C just allows you to actually express it
- School-Cotton 4y ago> it is a clear and precise syntax for expressing the operation the machine actually performs. No it’s not. Your compiler will almost certainly translate this into vector instructions, at least.
- School-Cotton 4y agoFor posterity, I was apparently wrong. It doesn’t autovectorize, with gcc 12.2 -O3 on godbolt, at least.
- mypalmike 4y agoC lacks the expression of many useful common CPU capabilities. Integer rotation and overflow checking come to mind immediately.