# Pipes in Symbols

**URL:** https://racket.discourse.group/t/pipes-in-symbols/1540
**Category:** Questions & Answers
**Created:** [December 7, 2022, 1:47am UTC](https://racket.discourse.group/t/pipes-in-symbols/1540 "2022-12-07T01:47:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@greg](https://racket.discourse.group/u/greg)
#### Post date: [December 7, 2022, 1:47am UTC](https://racket.discourse.group/t/pipes-in-symbols/1540/1 "2022-12-07T01:47:34Z")

</div>

The pipe sign (`|`) is sometimes used to [enclose symbols](https://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._string-~3esymbol%29%29). Is there more information about when one might want or need to do this? The only example I could come up with is the empty symbol (`'||`) which as far as I can tell cannot be represented otherwise.

---

<div class="post-metadata">

### Author: ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)
#### Post date: [December 7, 2022, 2:42am UTC](https://racket.discourse.group/t/pipes-in-symbols/1540/2 "2022-12-07T02:42:42Z")

</div>

If you have spaces in the symbol's name then it can be more convenient to use `|` than escaping them with `\`. Ditto for other characters that would normally terminate the symbol (like parentheses or semicolons).

---

<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: [December 7, 2022, 2:56am UTC](https://racket.discourse.group/t/pipes-in-symbols/1540/3 "2022-12-07T02:56:40Z")

</div>

Yes, `|` is used to delimit symbols that could not otherwise be written in concrete syntax. (There are alternatives, in particular `\` escapes.) Every possible string has a corresponding symbol (given `string->symbol`): using `\` can make it much easier to write some symbols in source code.

The parsing rules for symbols are very flexible: roughly, a delimited sequence of characters parses as a symbol unless it parses as something else. That makes it a little tricky to exhaustively list cases when escapes are needed. One particularly notable case is creating symbols that would otherwise parse as numbers, such as `|42|` (recall that `'42` instead evaluates to the number `42`, so `(and (symbol? '|42|) (number? '42))`). Symbols containing whitespace, e.g. `|Height of Giraffe|`, or punctuation, e.g. `|\|` or `|,|`, can also be useful in some contexts, such as working with data or implementing domain-specific languages.

There are more details on the syntax of symbols at [1.3.2 Reading Symbols](https://docs.racket-lang.org/reference/reader.html#%28part._parse-symbol%29) and details about `|` and `\` specifically at [1.3.1 Delimiters and Dispatch](https://docs.racket-lang.org/reference/reader.html#%28part._default-readtable-dispatch%29).

---

<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: [December 7, 2022, 10:02am UTC](https://racket.discourse.group/t/pipes-in-symbols/1540/4 "2022-12-07T10:02:42Z")

</div>

In Scribble programs I use `@|a|b` instead of `@a b` to avoid a space between a and b.

---

<div class="post-metadata">

### Author: ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)
#### Post date: [December 7, 2022, 2:53pm UTC](https://racket.discourse.group/t/pipes-in-symbols/1540/5 "2022-12-07T14:53:22Z")

</div>

Also in scribble: one way to document a parameter named `@a` is to use `|@a|` (this happens frequently with gui-easy programs such as [https://github.com/benknoble/frosthaven-manager/blob/e8df89f71deefa0a0d4918f18c53544670b35d43/scribblings/reference.scrbl#L629](https://github.com/benknoble/frosthaven-manager/blob/e8df89f71deefa0a0d4918f18c53544670b35d43/scribblings/reference.scrbl#L629), [https://github.com/benknoble/frosthaven-manager/blob/e8df89f71deefa0a0d4918f18c53544670b35d43/scribblings/reference.scrbl#L856](https://github.com/benknoble/frosthaven-manager/blob/e8df89f71deefa0a0d4918f18c53544670b35d43/scribblings/reference.scrbl#L856)).
