
I’m far from a macro expert (yet) but I don’t see why it’d be difficult to write a macro to do what you want. In spite of superficial similarities, ’(a b c) and (list a b c) are two different things and have different shapes. ’(a b c) is really (quote (a b c)). At the minimum it should be a quite simple matter of having your macro match on the two different shapes and process ’(a b c) into “a b c” using standard string functions and return (list a b c) as a list.

@samth @mflatt that test is meant to check that (for “well-behaved” connection types), long-running queries don’t block the execution of other racket threads. I don’t know a good way to test that directly, so it’s written using heuristics that Seemed To Work At The Time.

@me1 @abmclin With the default reader, '(a b c)
equals (quote (a b c))
equals (list 'a 'b 'c)
. I’m not sure you can tell the difference in a regular macro.

Hey, it works.

@dedbox that isn’t true. '(a b c)
does read as (quote (a b c))
, but expansion stops at quote
.

@lexi.lambda so in (quote (a b c))
, the (a b c)
part is an unexpanded list?

@dedbox I don’t know what you mean by “unexpanded list”. consider reading this https://stackoverflow.com/a/34984553/465378

@lexi.lambda just trying to figure out what we’re calling things. Still not sure how my original statement isn’t true.

well, macros operate on syntax. so while '(a b c)
does indeed become (quote (a b c))
at the reader level, it’s quite distinct from (list (quote a) (quote b) (quote c))
at the syntax level, which is the level macros operate at.

you could write: #lang racket
(require (for-syntax racket) syntax/parse/define)
(define-syntax-parser mac
#:literals [quote]
[(_ '(id:id ...)) #`(quote #,(datum->syntax #f (string-append* (map (compose1 symbol->string syntax-e) (attribute id)))))]
[(_ other:expr) #'other])

ohh.. ok, I was confused about the ordering.

thanks!

mhmm. the order of evaluation is read -> macroexpand -> compile -> runtime eval. '(a b c)
and (list 'a 'b 'c)
do indeed evaluate to the same thing at runtime, but they are distinct expressions, so prior phases can distinguish them.

I tried this: racket@foo.rkt>
(define-syntax f
(syntax-rules (list quote)
[(f '(a b c)) "tick"]
[(f (quote (a b c))) "quote"]
[(f (list a b c)) "list"]))
racket@foo.rkt> (f '(a b c))
"tick"
racket@foo.rkt> (f (quote (a b c)))
"tick"
racket@foo.rkt> (f (list 'a 'b 'c))
"list"

and this: racket@foo.rkt> (and (equal? '(a b c) (list 'a 'b 'c))
(equal? '(a b c) (quote (a b c))))
#t

yes, equal?
compares the expressions after evaluation (since it is just a regular function).

the 'x
-> (quote x)
translation happens in the reader, which is before macroexpansion, so those two are indistinguishable to macros.

just about to ask that

there are infinitely many distinct expressions that produce '(a b c)
when evaluated, so macros can’t detect (without evaluation) “an expression that evaluates to '(a b c)
”, since that would solve the halting problem. they can only make decisions based on the syntactic structure of their subforms.

<3Lisp

is it possible to write a macro so that ([function name] a b c) becomes (function-name a b c) ?

yes #lang racket
(require (for-syntax racket syntax/parse/class/paren-shape) syntax/parse/define (prefix-in r: racket))
(define-syntax-parser #%app
[[~brackets _ i:id ...+] (datum->syntax (first (attribute i)) (string->symbol (string-join (map (compose1 symbol->string syntax-e) (attribute i)) "-")))]
[(_ other ...) #'(r:#%app other ...)])
but I wouldn’t recommend it.