Replies: 4 comments
-
Spec wording instead of numbers does make sense, considering how often an editorial spec change renumbers everything below it without making any real change to the algorithm. As for implementing steps "obviously", the spec often implicitly assumes variables are mutable, dynamically typed, and garbage-collected, and most of the non-trivial algorithms I touched had at least one non-obvious point in their implementation to line them up with the way Rust variables work. The average method that handles more than a few steps probably needs at least one internal comment. |
Beta Was this translation helpful? Give feedback.
-
I remain strongly in favour of comments that indicate all steps of algorithms based on my experience understanding code as a reviewer and reading code later. That being said, we used to paraphrase the spec we were implementing, then some members of the team pushed back and said that was redundant so we moved to numbered steps. |
Beta Was this translation helpful? Give feedback.
-
If every step is going to be commented, numbers are a less tedious way to do it than words. To mitigate out-of-dateness, maybe functions with numbered steps could have an additional link to the specific spec version the numbers came from, so when they go out of date the renumbering is easily observed? |
Beta Was this translation helpful? Give feedback.
-
I think I would rather keep the status-quo, than start adding more precise information, in the sense that my point is that we should not aim for precise documentation of spec steps. I agree that the numbering is useful during an initial review, and what I meant is that it does tend to get out of date after some time, which is not that big of a problem(it's not that hard to find the renumbered step), rather it does call into question whether we need the numbers in the code in the first place. Example: servo/components/script/fetch.rs Line 220 in 7010178 This refers to Step 4.1 of I think https://fetch.spec.whatwg.org/#fetch-method Now this seems to have become Step 9.3 However, That step is actually part of sub-steps for the "#process-response" task referred to as https://fetch.spec.whatwg.org/#ref-for-process-response%E2%91%A1 (the first ref to https://fetch.spec.whatwg.org/#process-response). So I think it would be much clearer, and robust to numbering changes, to actually link to https://fetch.spec.whatwg.org/#process-response at servo/components/script/fetch.rs Line 211 in 7010178 This link is actually absent from the current code, and then perhaps add a servo/components/script/fetch.rs Line 221 in 7010178 // Step 4.1 .
So I'm not saying that the current |
Beta Was this translation helpful? Give feedback.
-
This is not a proposed change to code, rather to review practice.
I propose we stop numbering spec steps in the code, for the following reasons:
I propose that instead, besides adding a link to the relevant algorithm at the top of a function, we only add comments in the body when doing something that isn't obvious(or calls into some other part of the system), and then we comment not with a number but by actually writing it down in English, probably copy/pasting the actual line in the spec(the actual wording of a step doesn't change as often as its numbering).
Looking forward to your thoughts.
Beta Was this translation helpful? Give feedback.
All reactions