Hi Racketeers,

I've got what seems like a common way to use a #lang, make the
#%module-begin provide a certain name and use a local-require to get the
contents. I'm using Jens Axel's urlang and including the compiled
JavaScript in some Xexpressions later on. Here's how I've set up my
#%module-begin for the urlang #lang:

(define-syntax-rule (module-begin body ...)
  (#%plain-module-begin
   (provide the-javascript)
   (define (the-javascript)
     (with-output-to-string
       (λ () (compile #'(urmodule mod body ...)))))))

Getting the compiled JavaScript is relatively easy...

(let ()
  (local-require "js/test.rkt")
  (the-javascript))

However, attempting to abstract this into a macro is less easy ;). Here
was my first attempt:

(define-syntax-rule (urlang-js modpath)
  (let ()
    (local-require (only-in modpath the-javascript))
    (the-javascript)))

... later on ...

(urlang-js "js/test.rkt")

; main.rkt:15:11: the-javascript: unbound identifier
;   in: the-javascript
;   context...:
;    [common scopes]
;   other binding...:
;    local
;    #(82760 local) #(82761 intdef) [common scopes]
;   common scopes...:
;    #(82611 module) #(82614 module main) #(82766 local) #(82767 intdef)
; [Due to errors, REPL is just module language, requires, and stub definitions]

Oops. (Wasn't even able to (eval (expand #'(urlang-js "js/test.rkt"))))

Attempted to fix after digging thru docs and finding
syntax-local-introduce:

(define-syntax (urlang-js stx)
  (syntax-case stx ()
    [(_ modpath)
     #`(let ()
         #,(syntax-local-introduce
            #'(local-require (only-in modpath the-javascript)))
         (the-javascript))]))

Fixed usage within eval, but still no dice introducing urlang-js in
code.

Advice? Is there just a better way of doing this than a #lang maybe?

Thanks,

Jack

-- 
Jack M. Rosenthal
http://jack.rosenth.al

We guarantee that each number is random individually, but we
don't guarantee that more than one of them is random.
    -- early PMMLCG vendor

-- 
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.

Attachment: signature.asc
Description: PGP signature

Reply via email to