reference: add pointers to immutable?

When reading just the vector section of the Reference, it's
not obvious that `immutable?` distinguishes immutable vectors,
so add a note there. And the same for sttrings, etc. The section
on boxes was missing the usual paragraph on mutability.

Based on a suggestion from Shriram.
This commit is contained in:
Matthew Flatt 2019-08-27 15:52:58 -06:00
parent 800ea98525
commit 1e2019f600
5 changed files with 15 additions and 2 deletions

View File

@ -15,6 +15,8 @@ string is provided to a procedure like @racket[bytes-set!], the
@exnraise[exn:fail:contract]. Byte-string constants generated by the @exnraise[exn:fail:contract]. Byte-string constants generated by the
default reader (see @secref["parse-string"]) are immutable, default reader (see @secref["parse-string"]) are immutable,
and they are @tech{interned} in @racket[read-syntax] mode. and they are @tech{interned} in @racket[read-syntax] mode.
Use @racket[immutable?] to check whether a byte string is
immutable.
Two byte strings are @racket[equal?] when they have the same length Two byte strings are @racket[equal?] when they have the same length
and contain the same sequence of bytes. and contain the same sequence of bytes.

View File

@ -90,6 +90,14 @@ for each pair of keywords is the same as using
A @deftech{box} is like a single-element vector, normally used as A @deftech{box} is like a single-element vector, normally used as
minimal mutable storage. minimal mutable storage.
A box can be @defterm{mutable} or
@defterm{immutable}. When an immutable box is provided to a
procedure like @racket[set-box!], the
@exnraise[exn:fail:contract]. Box constants generated by the
default reader (see @secref["parse-string"]) are
immutable. Use @racket[immutable?] to check whether a box is
immutable.
A literal or printed box starts with @litchar{#&}. @see-read-print["box"]{boxes} A literal or printed box starts with @litchar{#&}. @see-read-print["box"]{boxes}
@defproc[(box? [v any/c]) boolean?]{ @defproc[(box? [v any/c]) boolean?]{

View File

@ -25,7 +25,8 @@ table is also either mutable or immutable. Immutable hash tables
support effectively constant-time access and update, just like mutable support effectively constant-time access and update, just like mutable
hash tables; the constant on immutable operations is usually larger, hash tables; the constant on immutable operations is usually larger,
but the functional nature of immutable hash tables can pay off in but the functional nature of immutable hash tables can pay off in
certain algorithms. certain algorithms. Use @racket[immutable?] to check whether a hash
table is immutable.
@margin-note{Immutable hash tables actually provide @math{O(log N)} @margin-note{Immutable hash tables actually provide @math{O(log N)}
access and update. Since @math{N} is limited by the address space so access and update. Since @math{N} is limited by the address space so

View File

@ -14,6 +14,7 @@ procedure like @racket[string-set!], the
@exnraise[exn:fail:contract]. String constants generated by the @exnraise[exn:fail:contract]. String constants generated by the
default reader (see @secref["parse-string"]) are default reader (see @secref["parse-string"]) are
immutable, and they are @tech{interned} in @racket[read-syntax] mode. immutable, and they are @tech{interned} in @racket[read-syntax] mode.
Use @racket[immutable?] to check whether a string is immutable.
Two strings are @racket[equal?] when they have the same length and Two strings are @racket[equal?] when they have the same length and
contain the same sequence of characters. contain the same sequence of characters.

View File

@ -16,7 +16,8 @@ the values in corresponding slots of the vectors are
A vector can be @defterm{mutable} or @defterm{immutable}. When an A vector can be @defterm{mutable} or @defterm{immutable}. When an
immutable vector is provided to a procedure like @racket[vector-set!], immutable vector is provided to a procedure like @racket[vector-set!],
the @exnraise[exn:fail:contract]. Vectors generated by the default the @exnraise[exn:fail:contract]. Vectors generated by the default
reader (see @secref["parse-string"]) are immutable. reader (see @secref["parse-string"]) are immutable. Use
@racket[immutable?] to check whether a vector is immutable.
A vector can be used as a single-valued sequence (see A vector can be used as a single-valued sequence (see
@secref["sequences"]). The elements of the vector serve as elements @secref["sequences"]). The elements of the vector serve as elements