The error is `set!` reporting that `doc` is undefined, because the `doc`
identifier from `md-module-begin` is introduced hygienically. Also, I
believe your pattern for `md-module-begin` has an extra set of parentheses.
Here is a working version:

#lang racket/base

#lang racket/base

(module lang racket/base
  (require syntax/wrap-modbeg
           (for-syntax racket/base
                       syntax/parse))
  (provide (except-out (all-from-out racket/base)
                       #%module-begin)
           (rename-out [md-module-begin #%module-begin]))
  (define-syntax handle
    (syntax-parser
      [(_ b:expr)
       #:with doc (syntax-local-introduce (datum->syntax #f 'doc))
       #`(set! doc (string-append doc b))]))
  (define-syntax wrapping-modbeg
    (make-wrapping-module-begin #'handle))
  (define-syntax md-module-begin
    (syntax-parser
      [(_ expr1 ...)
       #:with doc (syntax-local-introduce (datum->syntax #f 'doc))
       #'(wrapping-modbeg (define doc "")
                          expr1 ...)])))

(module example (submod ".." lang)
  (provide doc)
  "Example")

(require (submod "." example))

doc



-Philip

On Sat, Aug 18, 2018 at 3:36 AM, Vityou <zlee...@gmail.com> wrote:

> Stupid question, but how would I saving them in a global variable?  So far
> I have this:
>
> (define-syntax handle
>   (syntax-parser
>     [(_ b:expr) #`(set! #,(syntax-local-introduce (datum->syntax #f 'doc))
> (string-append #,(syntax-local-introduce (datum->syntax #f 'doc)) b))]))
>
> (define-syntax wrapping-modbeg
>   (make-wrapping-module-begin #'handle))
>
> (define-syntax md-module-begin
>   (syntax-parser
>     [(_ (expr1 ...)) #'(wrapping-modbeg (define doc "")
>                                         expr1 ...)]))
>
> However, it complains that `set!` isn't defined.  I thought it would be
> defined since my module provides `racket/base`.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to