I want to do a macro helper that returns a positive integer. Suppose that function has to return the integer n. What is the best option, n or #’n?
A syntax transformer must return a syntax object. You can do something like: #lang racket
(require (for-syntax syntax/parse))
(define-syntax (add1 stx)
(syntax-parse stx
[(_add1 n:integer)
; compute output value
(define n+1 (+ (syntax->datum #'n) 1))
; turn the value into syntax
(with-syntax ([n+1 n+1])
#'n+1)]))
(add1 41)
The problem is I want a procedure (in fase 1) that I will use to do a macro. Specifically, I want to calculate the length of a syntax object (where its datum is a list)
There is a syntax-length
ready to use in …
really?
unstable/syntax
Maybe (length (syntax->list stx))
is better?
It is what I was looking for. Thank you!