DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(r5rs.info.gz) External representations

Info Catalog (r5rs.info.gz) Disjointness of types (r5rs.info.gz) Basic concepts (r5rs.info.gz) Storage model
 
 3.3 External representations
 ============================
 
 An important concept in Scheme (and Lisp) is that of the _external
 representation_ of an object as a sequence of characters.  For example,
 an external representation of the integer 28 is the sequence of
 characters "28", and an external representation of a list consisting of
 the integers 8 and 13 is the sequence of characters "(8 13)".
 
 The external representation of an object is not necessarily unique.  The
 integer 28 also has representations "#e28.000" and "#x1c", and the list
 in the previous paragraph also has the representations "( 08 13 )" and
 "(8 . (13 . ()))" (see section  Pairs and lists).
 
 Many objects have standard external representations, but some, such as
 procedures, do not have standard representations (although particular
 implementations may define representations for them).
 
 An external representation may be written in a program to obtain the
 corresponding object (see `quote', section  Literal expressions).
 
 External representations can also be used for input and output.  The
 procedure `read' (section  Input) parses external
 representations, and the procedure `write' (section  Output)
 generates them.  Together, they provide an elegant and powerful
 input/output facility.
 
 Note that the sequence of characters "(+ 2 6)" is _not_ an external
 representation of the integer 8, even though it _is_ an expression
 evaluating to the integer 8; rather, it is an external representation
 of a three-element list, the elements of which are the symbol + and the
 integers 2 and 6.  Scheme's syntax has the property that any sequence
 of characters that is an expression is also the external representation
 of some object.  This can lead to confusion, since it may not be
 obvious out of context whether a given sequence of characters is
 intended to denote data or program, but it is also a source of power,
 since it facilitates writing programs such as interpreters and
 compilers that treat programs as data (or vice versa).
 
 The syntax of external representations of various kinds of objects
 accompanies the description of the primitives for manipulating the
 objects in the appropriate sections of chapter  Standard
 procedures.
 
Info Catalog (r5rs.info.gz) Disjointness of types (r5rs.info.gz) Basic concepts (r5rs.info.gz) Storage model
automatically generated byinfo2html