Wednesday, February 20, 2013

grammar - How to punctuate a sentence ending in a code block on

A lot of time when I'm writing a Programming Puzzles & Code Golf challenge, I need to incorporate multiline blocks of code



like

this


into my sentences.



Many times, it's simplest to have them at the very end of a sentence. For example, this scenario is easy to envision:




If the input is 1, the output of your program should be




sample output 1


If the input is 2, the output of your program should be



sample output 2



The problem is that there are supposed to be two complete sentences here, but there are no periods!




One obvious solution is to add periods after the code blocks:




If the input is 1, the output of your program should be



sample output 1


. If the input is 2, the output of your program should be




sample output 2


.




But this just looks weird.



Another solution is to add 'this:' after the 'be', and forgo the periods:





If the input is 1, the output of your program should be this:



sample output 1


If the input is 2, the output of your program should be this:



sample output 2




(I don't think it's grammatically correct to just put the colon after 'be' but I may be wrong.)



This seems more complete, but is still rather awkward with the 'this'es, and won't always work if the sentence is more complex. e.g.




The program




example code A


runs better than



example code B


[comma?] but both are worse than




example code C


[period?]




So what's the best way to do this - specifically on where it's impossible to put a period directly after a code block?

No comments:

Post a Comment