[racket-dev] style guide on blank lines

From: John Clements (clements at brinckerhoff.org)
Date: Tue Mar 13 02:16:47 EDT 2012

The style guide has this to say about blank lines:

"5.8 Spaces

Don’t pollute your code with spaces at the end of lines and extraneous blank lines."

This comes out pretty strongly against "extraneous" blank lines. In writing the code below, though, it seems to me that the blank lines aid readability, and that the version without them (below) just looks scary. Opinions?

(To be fair, you really have to view the following in DrR, not in your e-mail program.)

First, with extraneous blank lines:

;; flag-teachpack-requires : syntax nat -> syntax
;; apply the 'stepper-skip-completely hint to all
;; teachpack requires.
;; -- it would be great to do this directly when the 
;; requires are added, but they're not yet syntax there,
;; and this seems like the easiest way to fix it.
(define (flag-teachpack-requires stx num-teachpacks)
  (syntax-case stx ()
    [(mod name lang bodies-stx ...)
     (begin
       
       (define bodies (syntax->list #'(bodies-stx ...)))
       
       (when (< (length bodies) num-teachpacks)
         (error 'flag-teachpack-requires
                "internal error: expected bodies to include teachpack requires, got: ~e"
                bodies))
       
       ;; these should be the teachpack requires:
       (define-values (teachpack-requires remaining-bodies)
         (split-at bodies num-requires))
       
       (unless (andmap require-form? teachpack-requires)
         (error 'flag-teachpack-requires
                "internal error: expected these to be teachpack requires: ~e"
                teachpack-requires))
       
       (define flagged-teachpack-requires
         (for/list ([tp-rq (in-list teachpack-requires)])
           (stepper-syntax-property stx 'stepper-ignore-completely #t)))
       
       #'(mod name lang
              #, at flagged-teachpack-requires
              #, at remaining-bodies))]))


Then, without them:

;; flag-teachpack-requires : syntax nat -> syntax
;; apply the 'stepper-skip-completely hint to all
;; teachpack requires.
;; -- it would be great to do this directly when the 
;; requires are added, but they're not yet syntax there,
;; and this seems like the easiest way to fix it.
(define (flag-teachpack-requires stx num-teachpacks)
  (syntax-case stx ()
    [(mod name lang bodies-stx ...)
     (begin       
       (define bodies (syntax->list #'(bodies-stx ...)))
       (when (< (length bodies) num-teachpacks)
         (error 'flag-teachpack-requires
                "internal error: expected bodies to include teachpack requires, got: ~e"
                bodies))
       ;; these should be the teachpack requires:
       (define-values (teachpack-requires remaining-bodies)
         (split-at bodies num-requires))
       (unless (andmap require-form? teachpack-requires)
         (error 'flag-teachpack-requires
                "internal error: expected these to be teachpack requires: ~e"
                teachpack-requires))
       (define flagged-teachpack-requires
         (for/list ([tp-rq (in-list teachpack-requires)])
           (stepper-syntax-property stx 'stepper-ignore-completely #t)))
       #'(mod name lang
              #, at flagged-teachpack-requires
              #, at remaining-bodies))]))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120312/2f38de02/attachment.p7s>

Posted on the dev mailing list.