Last active
July 26, 2016 22:31
-
-
Save codemac/53201db0ac36b585e81745be8553504b to your computer and use it in GitHub Desktop.
Some scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-syntax define-maker | |
(lambda (stx) | |
(syntax-case stx () | |
((_ name) | |
#`(define | |
#,(datum->syntax | |
#'name | |
(string->symbol | |
(string-append | |
"make-" | |
(symbol->string | |
(syntax->datum #'name))))) | |
(lambda () (display "hello!"))))))) | |
(define-maker bob) | |
(make-bob) |
Current bug:
; guile --no-auto-compile struct.scm
ice-9/psyntax.scm:1388:26: In procedure rebuild-macro-output:
ice-9/psyntax.scm:1388:26: Syntax error:
unknown location: encountered raw symbol in macro output in subform make-bob of (define-maker bob)
15:25 <ijp> codemac: basically, rather than deal with symbols,
macros deal with syntax objects which carry around some
extra information (source location, lexical
environment, etc.)
15:25 <ijp> syntax->datum strips it, datum->syntax adds it
15:26 <ijp> the first argument to datum->syntax is an identifier
whose information to use for the datum
15:26 <ijp> so (datum->syntax #'name (string->symbol ...)) here
15:26 *** phant0mas QUIT Ping timeout: 258 seconds
15:27 <ijp> we should add an identifier-append, or an
identifier-format or something
15:27 <codemac> that would be neat!
15:28 <ijp> everyone has probably written their own
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, the problem was
#'
instead of