3
votes

How can we write a nothing macro that expands the following lines as described in their comments?

(nothing + 1 2) ; -> (+ 1 2)
(+ 1 nothing 2) ; -> (+ 1 2)
(nothing)       ; ->         ; (just a blank line)

Something like the following would work if the occurrences of #'0 could be replaced with "the empty syntax", if such a thing exists.

(define-syntax (nothing stx)
  (syntax-parse stx
    [(nothing) #'0]
    [(nothing body ...) #'(body ...)]
    [nothing #'0]))

So I suppose the question could be, "how do you represent empty syntax in racket?", but this is the context.

1

1 Answers

4
votes

There is no concept of "empty syntax". The closest you can get, is to produce an expression that does nothing. For example (void) or (begin) depending on the context.