# Can't I use symbols in case?

**URL:** <https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310>\
**Category:** Questions & Answers\
**Created:** [July 6, 2026, 8:48pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310 "2026-07-06T20:48:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [July 6, 2026, 8:48pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310/1 "2026-07-06T20:48:07Z")

</div>

Check out this small snippet from the REPL:

```scheme
> (define (foo p) (case p (('bar) 1) (else 2)))
> (foo 'bar)
2

```

I expected to the call `(foo 'bar)` would return 1. Why is `'bar` not matched?

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [July 6, 2026, 9:05pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310/2 "2026-07-06T21:05:21Z")

</div>

Well, the short version here is: don't use case, it's a very old form and has surprising conventions. Specifically, in this case, the elements in the matching clauses are automatically quoted, so you probably wanted to write:

```scheme
> (define (foo p) (case p ((bar) 1) (else 2)))
> (foo 'bar)
1

```

---

<div class="post-metadata">

**Author:** ![MickeyKnox](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MickeyKnox](https://racket.discourse.group/u/MickeyKnox)\
**Post date:** [July 6, 2026, 9:08pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310/3 "2026-07-06T21:08:51Z")

</div>

What would you have me use instead of `case`? The closest thing would probably be `cond`; however I prefer `case` in cases when I have values to match, because the `cond` clauses are more verbose in this case.

---

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [July 6, 2026, 9:46pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310/4 "2026-07-06T21:46:25Z")

</div>

Usually it is better to use `match` than `case`:

```scheme
> (define (foo p)
    (match p
      ['bar 1]
      [_ 2]))
> (foo 'bar)
1

```

(One very niche reason when you actually might want `case` instead of `match` is when you care about the guarantee that “the `case` form can dispatch to a matching `case`-clause in _O(log N)_ time for _N_ datums.”)

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [July 6, 2026, 11:39pm UTC](https://racket.discourse.group/t/cant-i-use-symbols-in-case/4310/5 "2026-07-06T23:39:07Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/a/a319b67cd6e6ebf953765fefeeb8dbed5482f366.png)

Note the `(datum ...)`. This means you don't need the quote before the symbol.

The reader will turn `'bar` into `(quote bar)`, so

```scheme
(case p (('bar) 1) ...)

```

is the same as

```scheme
(case p ( ((quote bar)) 1) ...)

```

so the list of the datums in the case clause does not include a lone `bar` symbol.
