You're referring to section 4 of the program, which occurs at the bottom of page 2 here: https://shreevatsa.github.io/knuth-literate-programs/program... — in the typeset version, the text "If direction k allows a move, return 1; otherwise continue" is followed by the number 5, which means that the contents are in section 5 of the program. If you go to section 5 which is at the top of the next page (if viewing the PDF on a screen, you can simply click on the 5), you'll see the contents of the section (followed by "This code is used in section 4").
(It's also possible to define some code across multiple sections, e.g. the "<Subroutines 3>;" referenced in section 1 is defined across sections 3, 4, 6. All these conventions may seem unnecessary for a small program but they were devised for the medium-length (~20k lines) Pascal program TeX: https://mirrors.ctan.org/info/knuth-pdf/tex/tex.pdf and it's how Knuth now finds it most comfortable to program for programs of any length.)
(How does CWEB process this: ctangle replaces the text with the body of the loop; you could think of the entire `If direction |k| allows a move, |return 1|; otherwise |continue|` as a parameter-less macro with a long name, which is replaced by the preprocessor.)
@< ... @> provides a section name. In text rendered form these become references, in code blocks when the code is generated it'll substitute in the referenced code.
Comments
Last month, Knuth was playing with an Othello program written in CWEB [1].
This part looks confusing. There must be some actual code in the loop body, but it all looks like pseudo code?! How does CWEB process this?[1] https://www-cs-faculty.stanford.edu/~knuth/programs/othello....
This is the original Knuth-style "literate programming", and being able to do this is approximately the entire point of CWEB.
BTW, note that the .w source file is not meant to be read directly: it is intended to be run through cweave (which generates a .tex file), and then typeset. In this case, I have a (not very up-to-date) repo at https://github.com/shreevatsa/knuth-literate-programs of the literate programs from Knuth's website, and othello.pdf is here: https://shreevatsa.github.io/knuth-literate-programs/program...
You're referring to section 4 of the program, which occurs at the bottom of page 2 here: https://shreevatsa.github.io/knuth-literate-programs/program... — in the typeset version, the text "If direction k allows a move, return 1; otherwise continue" is followed by the number 5, which means that the contents are in section 5 of the program. If you go to section 5 which is at the top of the next page (if viewing the PDF on a screen, you can simply click on the 5), you'll see the contents of the section (followed by "This code is used in section 4").
(It's also possible to define some code across multiple sections, e.g. the "<Subroutines 3>;" referenced in section 1 is defined across sections 3, 4, 6. All these conventions may seem unnecessary for a small program but they were devised for the medium-length (~20k lines) Pascal program TeX: https://mirrors.ctan.org/info/knuth-pdf/tex/tex.pdf and it's how Knuth now finds it most comfortable to program for programs of any length.)
(How does CWEB process this: ctangle replaces the text with the body of the loop; you could think of the entire `If direction |k| allows a move, |return 1|; otherwise |continue|` as a parameter-less macro with a long name, which is replaced by the preprocessor.)
It's right below that:
https://ctan.org/pkg/cweb?lang=en - This has some reference documentation.
@< ... @> provides a section name. In text rendered form these become references, in code blocks when the code is generated it'll substitute in the referenced code.
Knuth got the memo—he wrote a well-known rejoinder to it; it's not surprising to find him using goto.
https://dl.acm.org/doi/10.1145/356635.356640
Structured Programming with go to Statements, Knuth, 1974