3 ms·
Interesting, I usually think of code as being easier to parse when it's laid out in 2D like this: enum { size = 8192 }; int main() { char *n
by kragen 5y ago
Interesting, I usually think of code as being easier to parse when it's laid out in 2D like this:
enum { size = 8192 };
int main()
{
char *n = "tmp.mmapcrash";
int f = open(n, O_RDWR | O_CREAT, 0666);
if (f < 0) err(errno, "open: %s", n);
for (size_t i = 0; i < size; i++) {
if (write(f, "x", 1) < 0) err(errno, "write");
}
....
rather than in 1D like this:
enum { size = 8192 }; int main() { char *n = "tmp.mmapcrash"; int f =
open(n, O_RDWR | O_CREAT, 0666); if (f < 0) err(errno, "open: %s", n);
for (size_t i = 0; i < size; i++) { if (write(f, "x", 1) < 0)
err(errno, "write"); } ...
Are you saying that your experience it's the other way around?
Pattern-matching makes some code a lot easier to express and understand, but it's true that there are some languages where you end up having to kind of hand-translate it into a nest of conditionals and whatnot. It's kind of mindless work, though, so I don't really feel like I'm missing anything important in the pattern-matching representation of conditionals in paperalgo.