Paste number 68229: Macros Misbehaving

Index of paste annotations: 5 | 4 | 3 | 2 | 1

Paste number 68229: Macros Misbehaving
Pasted by: arcfide
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9
Channel:#scheme
Paste contents:
Raw Source | XML | Display As
(define-syntax competitor-include
  (lambda (x)
    (syntax-case x ()
      [(_ name)
       (let ([name-string (syntax->datum #'name)])
         #`(include 
             #,(string-append name-string 
                 (string (directory-separator))
                 name-string ".ss")))])))
 
(define-syntax import-competitor
  (lambda (x)
    (syntax-case x ()
      [(_ player)
       #`(module 
           (#,(datum->syntax #'_ (string->symbol (syntax->datum #'player))))
           (import scheme)
           (include "timing.ss")
           (competitor-include player)
           (format #t "Importing ~a~n" player))])))
 
(define-syntax import-players
  (syntax-rules ()
    [(_ player ...)
     (begin (import-competitor player) ...)]))

Annotations for this paste:

Annotation number 5: of course it works
Pasted by: boogeyman
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9#5
Paste contents:
Raw Source | Display As
> (import-competitor arcfide)

Error: missing definition for export arcfide.
Type (debug) to enter the debugger.


Hmmm?  Does your arcfide/arcfide.ss have a definition of arcfide?

I tried it and it works!

Annotation number 4: Session
Pasted by: arcfide
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9#4
Paste contents:
Raw Source | Display As
> (import-competitor arcfide)

Error: missing definition for export arcfide.
Type (debug) to enter the debugger.
> 

Annotation number 3: Module form can't see definition
Pasted by: arcfide
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9#3
Paste contents:
Raw Source | Display As
(define-syntax competitor-include
  (lambda (x)
    (syntax-case x ()
      [(_ name)
       #`(#,(datum->syntax #'name 'include)
          #,(let ([name (symbol->string (syntax->datum #'name))])
              (string-append name 
                (string (directory-separator))     
                name ".ss")))])))

(define-syntax import-competitor
  (syntax-rules ()
    [(_ player)
     (module (player)
       (import scheme)
       (include "timing.ss")
       (competitor-include player)
       (format #t "Importing ~a~n" player))])) 

(define-syntax import-players
  (syntax-rules ()
    [(_ player ...)
     (begin (import-competitor player) ...)]))

Annotation number 2: Just to make sure we're on the same page
Pasted by: eli
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9#2
Paste contents:
Raw Source | Display As
(define-syntax competitor-include
  (lambda (x)
    (syntax-case x ()
      [(k name)
       #`(#,(datum->syntax #'k 'include)
          #,(let ([name (symbol->string (syntax->datum #'name))])
              (string-append name
                             (string (directory-separator))
                             name)))])))

Annotation number 1: DATUM->SYNTAX COMPETITOR-INCLUDE
Pasted by: arcfide
When:8 months, 3 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1GN9#1
Paste contents:
Raw Source | Display As
(define-syntax competitor-include
  (lambda (x)
    (syntax-case x ()
      [(_ name)
       #`(#,(datum->syntax x 'include)
           #,(string-append #`#,#'name
               (string (directory-separator))
               #`#,#'name))])))

Colorize as:
Show Line Numbers
Index of paste annotations: 5 | 4 | 3 | 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.