Skip to content

Instantly share code, notes, and snippets.

@iitalics
Last active May 22, 2017 22:29
Show Gist options
  • Save iitalics/458fc2d765d3da57d2d96a6c8c930fde to your computer and use it in GitHub Desktop.
Save iitalics/458fc2d765d3da57d2d96a6c8c930fde to your computer and use it in GitHub Desktop.
Issue with current implementation of make-variable-like-transformer
#lang racket
(require (for-syntax syntax/parse
syntax/transformer))
(provide #%module-begin
#%top-interaction
#%datum
(rename-out [my-app #%app]
[my-+ +]
[my-expr #%expression]))
(define-syntax my-app
(syntax-parser
[(_ f arg ...)
; if the function has the property 'label, then log the call
#:with f+ (local-expand #'f 'expression '())
#:with lbl (syntax-property #'f+ 'label)
(when (syntax-e #'lbl)
(printf "; function call to: ~v\n" (syntax-e #'lbl)))
#'(#%app f arg ...)]))
; (attempt to) give + a label using variable-like-transformer
(define-syntax my-+
(make-variable-like-transformer
(syntax-property #'+ 'label "plus function")))
; this macro is never invoked
(define-syntax my-expr
(syntax-parser
[(_ e)
#:do [(printf "; unwrapping #%expression")]
#'e]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment