Paste number 68229: Macros Misbehaving

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

Paste number 68229: Macros Misbehaving
Pasted by: arcfide
1 month, 3 weeks ago
#scheme | Context in IRC logs
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 1: DATUM->SYNTAX COMPETITOR-INCLUDE
Pasted by: arcfide
1 month, 3 weeks ago
Context in IRC logs
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
)
)
]
)
)
)

Annotation number 2: Just to make sure we're on the same page
Pasted by: eli
1 month, 3 weeks ago
Context in IRC logs
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 3: Module form can't see definition
Pasted by: arcfide
1 month, 3 weeks ago
Context in IRC logs
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 4: Session
Pasted by: arcfide
1 month, 3 weeks ago
Context in IRC logs
Paste contents:
Raw Source | Display As
> (import-competitor arcfide)

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

Annotation number 5: of course it works
Pasted by: boogeyman
1 month, 3 weeks ago
Context in IRC logs
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!

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

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