#lang scheme (provide define-if-unbound) ;; Simpler than version-case (define-syntax (define-if-unbound stx) (syntax-case stx () [(form (header . rest) . body) (syntax/loc stx (form header (lambda rest . body)))] [(_ name expr) (if (identifier-binding #'name) (syntax/loc stx (begin)) (syntax/loc stx (define name expr)))]))