This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/tables.html Multipage: http://www.whatwg.org/C#table-sorting-model Complete: http://www.whatwg.org/c#table-sorting-model Referrer: Comment: Use nested lists for loop "blocks" in table-sorting-algorithm Posted from: 99.237.75.191 User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36
As you might imagine, I started working on a patch for this feature in Blink, and the actual sorting algorithm is the big chunk, quite an eyeful of instructions! It also contains a number of what I would consider "block scope" kind of constructs, and these would be much, much easier to read if they were formatted as nested lists.
How would you phrase the steps that currently say "jump to the step labeled end below" if the "end" step wasn't in the same set of steps?
For example (does not go all the way to the end, because it's a rather long set of steps, but hey): https://gist.github.com/caitp/71a97bcb41fdb145b688 The prose used feels much more turing-complete and better suits the description of computer programmes --- but on top of that, it's much easier to visualize what should be happening. Replacing labeled steps with these constructs is much easier to read and comprehend (in my opinion).
"Repeat while row collection cursor is not null" doesn't work because if I ever add a step after the one that mutates "row collection cursor", it won't be clear what that means any more. But anyway, I guess your answer to comment 2 is just "leave them as is", i.e. you're fine with gotos that cross loop scopes. Is that right?
"doesn't work because if I ever add a step after the one that mutates "row collection cursor", it won't be clear what that means any more." Can you explain how it would not be clear anymore? The idea is, there are patterns that we use repeatedly (evaluate different lists of steps conditionally, depending on different inputs, repeat a set of steps until a terminating condition). It's the same pattern no matter how it's written, but writing it this way makes it much easier to identify the pattern at a glance, without having to digaround for terminating conditions. But yes, the formatting of the lists is much more important. Even with the labels everywhere, it's still much easier to understand when "scopes" are indented and formatted as children of the parent "scope".
It wouldn't work because "repeat while" in English means something different than "while" in programming languages. Anyway, I can add more indentation to this algorithm I guess.
Ok, let me know what you think of the update on IRC.
Checked in as WHATWG revision r8784. Check-in comment: Add in some clearer indentiation in the table sorting algorithm to make it easier to understand https://html5.org/tools/web-apps-tracker?from=8783&to=8784