forked from racket/racket
/
data.scrbl
173 lines (108 loc) · 5.57 KB
/
data.scrbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#lang scribble/doc
@(require "mz.rkt")
@title[#:style 'toc #:tag "data"]{Datatypes}
@guideintro["datatypes"]{Datatypes}
Each pre-defined datatype comes with a set of procedures for
manipulating instances of the datatype.
@local-table-of-contents[#:style 'immediate-only]
@; ------------------------------------------------------------
@include-section["booleans.scrbl"]
@; ------------------------------------------------------------
@include-section["numbers.scrbl"]
@; ------------------------------------------------------------
@include-section["strings.scrbl"]
@; ------------------------------------------------------------
@include-section["bytes.scrbl"]
@; ------------------------------------------------------------
@include-section["chars.scrbl"]
@; ------------------------------------------------------------
@include-section["symbols.scrbl"]
@; ------------------------------------------------------------
@include-section["regexps.scrbl"]
@; ------------------------------------------------------------
@section[#: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.}
@defproc[(keyword->string [keyword keyword?]) string?]{
Returns a string for the @racket[display]ed form of @racket[keyword],
not including the leading @litchar{#:}.}
@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{#:}.}
@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<?].}
@; ----------------------------------------------------------------------
@include-section["pairs.scrbl"]
@; ----------------------------------------------------------------------
@include-section["mpairs.scrbl"]
@; ----------------------------------------------------------------------
@include-section["vectors.scrbl"]
@; ------------------------------------------------------------
@section[#:tag "boxes"]{Boxes}
@guideintro["boxes"]{boxes}
A @deftech{box} is like a single-element vector, normally used as
minimal mutable storage.
A literal or printed box starts with @litchar{#&}. @see-read-print["box"]{boxes}
@defproc[(box? [v any/c]) boolean?]{
Returns @racket[#t] if @racket[v] is a box, @racket[#f] otherwise.}
@defproc[(box [v any/c]) box?]{
Returns a new mutable box that contains @racket[v].}
@defproc[(box-immutable [v any/c]) (and/c box? immutable?)]{
Returns a new immutable box that contains @racket[v].}
@defproc[(unbox [box box?]) any/c]{
Returns the content of @racket[box].}
For any @racket[v], @racket[(unbox (box v))] returns @racket[v].
@defproc[(set-box! [box (and/c box? (not/c immutable?))]
[v any/c]) void?]{
Sets the content of @racket[box] to @racket[v].}
@defproc[(box-cas! [box (and/c box? (not/c immutable?) (not/c impersonator?))]
[old any/c]
[new any/c])
boolean?]{
Atomically updates the contents of @racket[box] to @racket[new], provided
that @racket[box] currently contains a value that is @racket[eq?] to
@racket[old], and returns @racket[#t] in that case. If @racket[box]
does not contain @racket[old], then the result is @racket[#f].
If no other @tech{threads} or @tech{futures} attempt to access
@racket[box], the operation is equivalent to
@racketblock[
(and (eq? old (unbox loc)) (set-box! loc new) #t)]
When Racket is compiled with support for @tech{futures},
@racket[box-cas!] uses a hardware @emph{compare and set} operation.
Uses of @racket[box-cas!] be performed safely in a @tech{future} (i.e.,
allowing the future thunk to continue in parallel). }
@; ----------------------------------------------------------------------
@include-section["hashes.scrbl"]
@; ----------------------------------------------------------------------
@include-section["sequences.scrbl"]
@; ----------------------------------------------------------------------
@include-section["dicts.scrbl"]
@; ----------------------------------------------------------------------
@include-section["sets.scrbl"]
@; ----------------------------------------------------------------------
@include-section["procedures.scrbl"]
@; ----------------------------------------------------------------------
@section[#:tag "void"]{Void}
The constant @|void-const| is returned by most forms and procedures
that have a side-effect and no useful result.
The @|void-const| value is always @racket[eq?] to itself.
@defproc[(void? [v any/c]) boolean?]{Returns @racket[#t] if @racket[v] is the
constant @|void-const|, @racket[#f] otherwise.}
@defproc[(void [v any/c] ...) void?]{Returns the constant @|void-const|. Each
@racket[v] argument is ignored.}
@; ----------------------------------------------------------------------
@include-section["undefined.scrbl"]