{"size": 2450, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/scribblings/reference/keywords.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "pkgs/racket-doc/scribblings/reference/keywords.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "pkgs/racket-doc/scribblings/reference/keywords.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": null, "avg_line_length": 28.8235294118, "max_line_length": 80, "alphanum_fraction": 0.6808163265}
#lang scribble/doc
@(require "mz.rkt"
          (for-label racket/keyword))

@title[#:tag "keywords"]{Keywords}

@guideintro["keywords"]{keywords}

A @deftech{keyword} is like an @tech{interned} symbol, but its printed
form starts with @litchar{#:}, and a keyword cannot be used as an
identifier. Furthermore, a keyword by itself is not a valid
expression, though a keyword can be @racket[quote]d to form an
expression that produces the symbol.

Two keywords are @racket[eq?] if and only if they print the same
(i.e., keywords are always @tech{interned}).

Like symbols, keywords are only weakly held by the internal keyword
table; see @secref["symbols"] for more information.

@see-read-print["keyword"]{keywords}

@defproc[(keyword? [v any/c]) boolean?]{

Returns @racket[#t] if @racket[v] is a keyword, @racket[#f] otherwise.

@mz-examples[(keyword? '#:apple)
             (keyword? 'define)
             (keyword? '#:define)]}


@defproc[(keyword->string [keyword keyword?]) string?]{

Returns a string for the @racket[display]ed form of @racket[keyword],
not including the leading @litchar{#:}.

See also @racket[keyword->immutable-string] from
@racketmodname[racket/keyword].

@mz-examples[(keyword->string '#:apple)]}


@defproc[(string->keyword [str string?]) keyword?]{

Returns a keyword whose @racket[display]ed form is the same as that of
@racket[str], but with a leading @litchar{#:}.

@mz-examples[(string->keyword "apple")]}


@defproc[(keyword<? [a-keyword keyword?] [b-keyword keyword?] ...) boolean?]{

Returns @racket[#t] if the arguments are sorted, where the comparison
for each pair of keywords is the same as using
@racket[keyword->string] with @racket[string->bytes/utf-8] and
@racket[bytes<?].

@mz-examples[(keyword<? '#:apple '#:banana)]

@history/arity[]}


@; ----------------------------------------
@section{Additional Keyword Functions}

@note-lib[racket/keyword]
@(define keyword-eval (make-base-eval))
@examples[#:hidden #:eval keyword-eval (require racket/keyword)]

@history[#:added "7.6"]

@defproc[(keyword->immutable-string [sym keyword?]) (and/c string? immutable?)]{

Like @racket[keyword->string], but the result is an immutable string,
not necessarily freshly allocated.

@examples[#:eval keyword-eval
          (keyword->immutable-string '#:apple)
          (immutable? (keyword->immutable-string '#:apple))]

@history[#:added "7.6"]}

@; ----------------------------------------
@close-eval[keyword-eval]
