summaryrefslogtreecommitdiff
path: root/doc/lispref/objects.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref/objects.texi')
-rw-r--r--doc/lispref/objects.texi35
1 files changed, 31 insertions, 4 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index ad079e0d63a..13c5f06b0bd 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -1,6 +1,6 @@
@c -*- mode: texinfo; coding: utf-8 -*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990--1995, 1998--1999, 2001--2023 Free Software
+@c Copyright (C) 1990--1995, 1998--1999, 2001--2024 Free Software
@c Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@node Lisp Data Types
@@ -82,7 +82,9 @@ it does not make sense to enter objects of these types as constants in
a Lisp program. These objects are printed in @dfn{hash notation},
which consists of the characters @samp{#<}, a descriptive string
(typically the type name followed by the name of the object), and a
-closing @samp{>}. For example:
+closing @samp{>}. (This is called ``hash notation'' because it begins
+with the @samp{#} character, known as ``hash'' or ``number sign'').
+For example:
@example
(current-buffer)
@@ -94,6 +96,12 @@ Hash notation cannot be read at all, so the Lisp reader signals the
error @code{invalid-read-syntax} whenever it encounters @samp{#<}.
@kindex invalid-read-syntax
+ We describe the read syntax and the printed representation of each
+Lisp data type where we describe that data type, in the following
+sections of this chapter. For example, see @ref{String Type}, and its
+subsections for the read syntax and printed representation of strings;
+see @ref{Vector Type} for the same information about vectors; etc.
+
In other languages, an expression is text; it has no other form. In
Lisp, an expression is primarily a Lisp object and only secondarily the
text that is the object's read syntax. Often there is no need to
@@ -319,6 +327,8 @@ number whose value is 1500. They are all equivalent.
A @dfn{character} in Emacs Lisp is nothing more than an integer. In
other words, characters are represented by their character codes. For
example, the character @kbd{A} is represented as the @w{integer 65}.
+That is also their usual printed representation; see @ref{Basic Char
+Syntax}.
Individual characters are used occasionally in programs, but it is
more common to work with @emph{strings}, which are sequences composed
@@ -1104,6 +1114,22 @@ character. Likewise, you can include a backslash by preceding it with
another backslash, like this: @code{"this \\ is a single embedded
backslash"}.
+ Since a string is an array of characters, you can specify the string
+characters using the read syntax of characters, but without the
+leading question mark. This is useful for including in string
+constants characters that don't stand for themselves. Thus, control
+characters can be specified as escape sequences that start with a
+backslash; for example, @code{"foo\r"} yields @samp{foo} followed by
+the carriage return character. @xref{Basic Char Syntax}, for escape
+sequences of other control characters. Similarly, you can use the
+special read syntax for control characters (@pxref{Ctl-Char Syntax}),
+as in @code{"foo\^Ibar"}, which produces a tab character embedded
+within a string. You can also use the escape sequences for non-ASCII
+characters described in @ref{General Escape Syntax}, as in
+@w{@code{"\N@{LATIN SMALL LETTER A WITH GRAVE@}"}} and @code{"\u00e0"}
+(however, see a caveat with non-ASCII characters in @ref{Non-ASCII in
+Strings}).
+
@cindex newline in strings
The newline character is not special in the read syntax for strings;
if you write a new line between the double-quotes, it becomes a
@@ -1180,8 +1206,9 @@ but it does terminate any preceding hex escape.
as in character literals (but do not use the question mark that begins a
character constant). For example, you can write a string containing the
nonprinting characters tab and @kbd{C-a}, with commas and spaces between
-them, like this: @code{"\t, \C-a"}. @xref{Character Type}, for a
-description of the read syntax for characters.
+them, like this: @code{"\t, \C-a"}. @xref{Character Type}, and its
+subsections for a description of the various kinds of read syntax for
+characters.
However, not all of the characters you can write with backslash
escape-sequences are valid in strings. The only control characters that