# Unexpected behaviour of quasiquote when binding unquote and unquote-splicing

**URL:** <https://racket.discourse.group/t/unexpected-behaviour-of-quasiquote-when-binding-unquote-and-unquote-splicing/1700>\
**Category:** Questions & Answers\
**Tags:** quasiquote\
**Created:** [February 11, 2023, 8:29pm UTC](https://racket.discourse.group/t/unexpected-behaviour-of-quasiquote-when-binding-unquote-and-unquote-splicing/1700 "2023-02-11T20:29:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [February 11, 2023, 8:29pm UTC](https://racket.discourse.group/t/unexpected-behaviour-of-quasiquote-when-binding-unquote-and-unquote-splicing/1700/1 "2023-02-11T20:29:44Z")

</div>

```scheme
#lang racket/base

(let ((unquote-splicing 4) (unquote add1))
   `(a b unquote ,(map unquote '(0 1 2 3)) ,(unquote unquote-splicing))) 

```

--\>

```scheme
(a b unquote ,(map . ,'(0 1 2 3)) ,,unquote-splicing)

```

but should it not produce:

```scheme
(a b unquote (1 2 3 4) 5)

```

???

It seems that in parts of a datum in (quasiquote datum) at evaluation level  
syntax quasiquote does not see the rebinding of unquote and unquote-splicing.

I do not have this problem in my own toy interpreters.

---

<div class="post-metadata">

**Author:** ![rocketnia](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/rocketnia/32/153_2.png) [@rocketnia](https://racket.discourse.group/u/rocketnia)\
**Post date:** [February 11, 2023, 10:51pm UTC](https://racket.discourse.group/t/unexpected-behaviour-of-quasiquote-when-binding-unquote-and-unquote-splicing/1700/2 "2023-02-11T22:51:37Z")

</div>

To explain what's going on, the reader shorthands ` `_` `,_` `,@_` are unhygienic in Racket. They stand for two-element lists with symbols at the beginning, `(quasiquote _)` `(unquote _)` `(unquote-splicing _)`. They always mean whatever they would mean if you spelled them out.

This is a pretty weird situation, since `(let ...)` bindings don't interact with the behavior of most reader syntaxes, just ` `_` `,_` `,@_` `#`_` `#,_` `#,@_`. Rebinding `unquote`, as you've done, also effectively rebinds the meaning of `,_`. If it helps any to tolerate this, consider that rebinding `unquote` also rebinds the meanings of `|unquote|`, `un\quote`, and `#ci UnQuote`, Of course, those are a little different from a practical standpoint since the symbols they represent are more apparent in their textual form.

If you'd like to use Racket with the hygienic behavior you want now, Alex Knauth has made the `hygienic-quote-lang` package for this situation. Just now I tried your example in `#lang hygienic-quote racket`, and it produced what you said it should.

---

<div class="post-metadata">

**Author:** ![joskoot](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joskoot/32/1964_2.png) [@joskoot](https://racket.discourse.group/u/joskoot)\
**Post date:** [February 12, 2023, 10:56am UTC](https://racket.discourse.group/t/unexpected-behaviour-of-quasiquote-when-binding-unquote-and-unquote-splicing/1700/3 "2023-02-12T10:56:13Z")

</div>

To rocketnia

Thanks for the explanation.

Jos

 ![49C29F22FA914E7CA5B25D35AE6EFB5F.png](https://global.discourse-cdn.com/free1/uploads/racket/original/1X/2e839751fd263c2803de1577258c08f5c6235600.png)
