<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26660</bug_id>
          
          <creation_ts>2014-08-25 23:12:01 +0000</creation_ts>
          <short_desc>Use nested lists for loop &quot;blocks&quot; in table-sorting-algorithm</short_desc>
          <delta_ts>2014-09-17 22:58:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#table-sorting-model</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>caitpotter88</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>110562</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-08-25 23:12:01 +0000</bug_when>
    <thetext>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 &quot;blocks&quot; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110563</commentid>
    <comment_count>1</comment_count>
    <who name="caitp">caitpotter88</who>
    <bug_when>2014-08-25 23:13:55 +0000</bug_when>
    <thetext>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 &quot;block scope&quot; kind of constructs, and these would be much, much easier to read if they were formatted as nested lists.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110632</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-26 17:59:41 +0000</bug_when>
    <thetext>How would you phrase the steps that currently say &quot;jump to the step labeled end below&quot; if the &quot;end&quot; step wasn&apos;t in the same set of steps?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110636</commentid>
    <comment_count>3</comment_count>
    <who name="caitp">caitpotter88</who>
    <bug_when>2014-08-26 18:40:47 +0000</bug_when>
    <thetext>For example (does not go all the way to the end, because it&apos;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&apos;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).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110675</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-27 21:47:30 +0000</bug_when>
    <thetext>&quot;Repeat while row collection cursor is not null&quot; doesn&apos;t work because if I ever add a step after the one that mutates &quot;row collection cursor&quot;, it won&apos;t be clear what that means any more.

But anyway, I guess your answer to comment 2 is just &quot;leave them as is&quot;, i.e. you&apos;re fine with gotos that cross loop scopes. Is that right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110677</commentid>
    <comment_count>5</comment_count>
    <who name="caitp">caitpotter88</who>
    <bug_when>2014-08-27 21:59:35 +0000</bug_when>
    <thetext>&quot;doesn&apos;t work because if I ever add a step after the one that mutates &quot;row collection cursor&quot;, it won&apos;t be clear what that means any more.&quot;

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&apos;s the same pattern no matter how it&apos;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&apos;s still much easier to understand when &quot;scopes&quot; are indented and formatted as children of the parent &quot;scope&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110723</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-08-28 18:44:55 +0000</bug_when>
    <thetext>It wouldn&apos;t work because &quot;repeat while&quot; in English means something different than &quot;while&quot; in programming languages.

Anyway, I can add more indentation to this algorithm I guess.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111725</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-17 22:58:23 +0000</bug_when>
    <thetext>Ok, let me know what you think of the update on IRC.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111726</commentid>
    <comment_count>8</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-17 22:58:36 +0000</bug_when>
    <thetext>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&amp;to=8784</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>