Skip to content

Instantly share code, notes, and snippets.

@samdphillips
Created May 21, 2012 03:08
Show Gist options
  • Save samdphillips/2760405 to your computer and use it in GitHub Desktop.
Save samdphillips/2760405 to your computer and use it in GitHub Desktop.
racket hack for reporting shadowed bindings
#lang racket/base
(require (for-syntax racket/base)
(only-in racket/base
[define orig-define]))
(define-syntax (define stx)
(syntax-case stx ()
[(_ x e)
(when (identifier-binding #'x)
(printf "WARNING: ~a shadows an existing name~%" (syntax->datum #'x)))
#'(orig-define x e)]))
(define x 20)
(define list 0)
(define foo
(lambda ()
(define x 10)
(add1 x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment