3 ms·
That's one line, yes, but what a line! That's 20 tokens or so, many of which are weird and hairy (the ? operator, multiple assignments). And in Lisp style you'd
by philwelch 17y ago
That's one line, yes, but what a line! That's 20 tokens or so, many of which are weird and hairy (the ? operator, multiple assignments). And in Lisp style you'd have that as multiple lines anyway.
- Retric 17y agoTrue, but my point is it's more tokens if you write it as several lines. a = b = c 2; vs b = c 2; a = b; So token count is still not really what we want to measure even if it's better than line count.
- philwelch 17y ago"it's more tokens if you write it as several lines" As several lines or several statements? x = ____(a = 7 * ________(b = 14)) ____+ ____(c = 9 * ________((d > 7)? e:f)); Same statement, same token count, multiple lines.
- Retric 17y agoStatments, that's in no way easer to parse than that some code on a single line. (Assuming you have collar coding for the ()'s in your IDE.) c = 9 * ((d > 7)?e:f); x = ( a = 7 * (b = 14)) + c; IMO is not that bad, it's the mixing of all the assignments and the conditional that makes it hard to parse, and c = 9 * ((d > 7)?e:f); x = c + (a = 7 * (b = 14)); is fairly readable even if some of the ()'s are not needed. PS: ;'s I thought it was clear that the ;'s denoted lines not the whitespace which is meaningless.
- philwelch 17y agoSemicolons do denote statements, but that doesn't prevent you from clever use of line breaks. I still think my version is more readable.
- Retric 17y agoEdit: NM, reply is now working. I just wanted to say that personaly I have tryed learn to ignore indention and other clues becasue it's far more costly to misunderstand what the code is doing than try and use hint's that may have become old over time. To paraphrase: in that way lay bugs that look like dragons. I also tend to do the same thing with comments on the first pass though. It's only when I don't understand the code or or it looks "odd" that I start to notice the extras like that.
- Retric 17y agoI can't reply to: "Semicolons do denote statements, but that doesn't prevent you from clever use of line breaks. I still think my version is more readable." for some reason. I just wanted to say... Edit: NM, reply is now working so I moved the comment.