style guide addition?

34 views
Skip to first unread message

John Clements

unread,
Jan 21, 2020, 1:13:40 AM1/21/20
to Racket-Users List
I’m grading code, and one of my students keeps leaving out spaces in weird places:

(cond
[(< x 3)(+ x 1)]
[else (f(g 9))])

I took a quick look in the style guide, and it doesn’t seem to have much to say about this. Here’s what it has:

6.8 Spaces

Don’t pollute your code with spaces at the end of lines.

If you find yourself breaking long blocks of code with blank lines to aid readability, consider refactoring your program to introduce auxiliary functions so that you can shorten these long blocks of code. If nothing else helps, consider using (potentially) empty comment lines.

***

To this text, I would like to add:

“Every pair of expressions on a line should have at least one space between them, even if they’re separated by parens.

Wrong: [(< x 3)(+ x 1)]
Right: [(< x 3) (+ x 1)]

Wrong: (f(g 3))
Right: (f (g 3))


Can anyone think of exceptions to this? One possible nit: since the rule refers to “expressions”, it perhaps wouldn’t rule out (define(f x)3) . You could say “term”, but I think it would be less clear.

John



Jack Firth

unread,
Jan 21, 2020, 7:46:45 PM1/21/20
to Racket Users
I think that would be a great addition to the style guide. I agree that "expression" is clearer than "term", though I'm not too worried about it not covering (define(f x)3). We could add stronger language later on as we get a sense of how people react to the initial wording.
Reply all
Reply to author
Forward
0 new messages