For instance:
#lang racket
(provide a a)
(define a 1)
should result in an error.
This would help catching silly copy and paste mistakes like this:
#lang racket
(provide a-long-name a-long-name) ; forgot to change a-long-name to a-long-name*
(define a-long-name 1)
(define a-long-name* 2)
Concerns:
Such a change could break existing programs.
It is useful for require and provide to be "idempotent" when produced by macros.
(Speaking of macros, one way to avoid such mistakes is to define and use a define/provide macro? I feel like that's part of this theme.)
If you'd like to use provide instead of something like define/provide, I recommend keeping each provided identifier on its own line. This makes the duplication more immediately apparent:
#lang racket
(provide a-long-name
a-long-name) ; forgot to change a-long-name to a-long-name*
(define a-long-name 1)
(define a-long-name* 2)
Most helpful comment
Concerns:
Such a change could break existing programs.
It is useful for
requireandprovideto be "idempotent" when produced by macros.(Speaking of macros, one way to avoid such mistakes is to define and use a
define/providemacro? I feel like that's part of this theme.)