[plt-scheme] drscheme feature idea: automatically add missing exports for scheme modules

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon Jul 27 09:21:51 EDT 2009

2009/7/27 Neil Van Dyke <neil at neilvandyke.org>:
> I hadn't thought of that.  In my case, my embedded documentation serves a
> similar purpose.
>
> Just, before releasing a library, once the interface is solidly designed and
> documented I want to change the "provide all defined" to not include the "%"
> names, so that I'm not polluting namespaces of library users.

Is this what you are after?

/Jens Axel


#lang scheme
(require (for-syntax scheme/provide-transform)
         scheme/provide-syntax)

(begin-for-syntax
  (define (symbol<? x y)
    (apply string<? (map symbol->string (list x y))))
  (define (begins-with-%? sym)
    (char=? #\% (string-ref (symbol->string sym) 0))))


; (_ provide-spec)
(define-provide-syntax (all-except-%-out stx)
  (syntax-case stx ()
    [(_)
     (let ([exports (expand-export #'(all-defined-out) null)])
       (with-syntax
           ([(id ...) (filter (compose not begins-with-%? syntax-e)
                              (map export-local-id exports))])
         (syntax/loc stx (combine-out id ...))))]))

(define foo 1)
(define bar 2)
(define %a 3)
(define %b 4)

(provide (all-except-%-out))


Posted on the users mailing list.