GNU Info

Info Node: (emacs-lisp-intro.info)Data types

(emacs-lisp-intro.info)Data types


Next: Args as Variable or List Prev: Arguments Up: Arguments
Enter node , (file) or (file)node

Arguments' Data Types
---------------------

   The type of data that should be passed to a function depends on what
kind of information it uses.  The arguments to a function such as `+'
must have values that are numbers, since `+' adds numbers.  Other
functions use different kinds of data for their arguments.

   For example, the `concat' function links together or unites two or
more strings of text to produce a string.  The arguments are strings.
Concatenating the two character strings `abc', `def' produces the
single string `abcdef'.  This can be seen by evaluating the following:

     (concat "abc" "def")

The value produced by evaluating this expression is `"abcdef"'.

   A function such as `substring' uses both a string and numbers as
arguments.  The function returns a part of the string, a substring of
the first argument.  This function takes three arguments.  Its first
argument is the string of characters, the second and third arguments are
numbers that indicate the beginning and end of the substring.  The
numbers are a count of the number of characters (including spaces and
punctuations) from the beginning of the string.

   For example, if you evaluate the following:

     (substring "The quick brown fox jumped." 16 19)

you will see `"fox"' appear in the echo area.  The arguments are the
string and the two numbers.

   Note that the string passed to `substring' is a single atom even
though it is made up of several words separated by spaces.  Lisp counts
everything between the two quotation marks as part of the string,
including the spaces.  You can think of the `substring' function as a
kind of `atom smasher' since it takes an otherwise indivisible atom and
extracts a part.  However, `substring' is only able to extract a
substring from an argument that is a string, not from another type of
atom such as a number or symbol.


automatically generated by info2www version 1.2.2.9