On this page:
Symbol
#'
#'
#'
Symbol.from_  string
Symbol.uninterned_  from_  string
Symbol.unreadable_  from_  string
Symbol.gen
8.12

6.28 Symbols🔗ℹ

A symbol value reflects internal representation of syntax-object identifier content, without the binding or source-location information that is associated with an identifier. A symbol is similar to a string, but symbols are typically interned and they are equal by == only when they are equal by ===. The #' operator can produce a symbol value.

Symbols are comparable, which means that generic operations like < and > work on symbols. Comparsion of two symbols is the same as comparing the string forms of the symbols.

annotation

Symbol

Matches symbols.

expression

#' id

 

expression

#' keyword

 

repetition

#' id

 

repetition

#' keyword

 

binding operator

#' id

 

binding operator

#' keyword

As an expression, repetition, or binding, #' produces or matches a symbol or keyword, depending whether #' is followed by an identifier or keyword.

> #'hello

#'hello

> #'hello +& " there"

"hello there"

> #'~skeleton

#'~skeleton

> match #'goodbye

  | #'hello: "hi"

  | #'goodbye: "bye"

"bye"

Converts a string to a symbol with the same character content. An uninterned symbol is not equal to any other symbol, even ones with the same character content. An unreadable symbol is only equal to other unreadable symbols with the same character content.

> Symbol.from_string("apple")

#'apple

> Symbol.from_string("apple") == #'apple

#true

> Symbol.uninterned_from_string("apple")

#'apple

> Symbol.uninterned_from_string("apple")

    == Symbol.uninterned_from_string("apple")

#false

> Symbol.unreadable_from_string("apple")

#'apple

> Symbol.unreadable_from_string("apple") == #'apple

#false

> Symbol.unreadable_from_string("apple")

    == Symbol.unreadable_from_string("apple")

#true

function

fun Symbol.gen() :: Symbol

 

function

fun Symbol.gen(name :: ReadableString || Symbol) :: Symbol

Produces an uninterned symbol with a character content optionally derived from name (typically with digits appended as a debugging aid).