DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Simple Invocation

Info Catalog (guile.info.gz) Procedures as Values (guile.info.gz) About Procedures (guile.info.gz) Creating a Procedure
 
 14.2.2 Simple Procedure Invocation
 ----------------------------------
 
 A procedure invocation in Scheme is written like this:
 
      (PROCEDURE [ARG1 [ARG2 ...]])
 
    In this expression, PROCEDURE can be any Scheme expression whose
 value is a procedure.  Most commonly, however, PROCEDURE is simply the
 name of a variable whose value is a procedure.
 
    For example, `string-append' is a standard Scheme procedure whose
 behaviour is to concatenate together all the arguments, which are
 expected to be strings, that it is given.  So the expression
 
      (string-append "/home" "/" "andrew")
 
 is a procedure invocation whose result is the string value
 `"/home/andrew"'.
 
    Similarly, `string-length' is a standard Scheme procedure that
 returns the length of a single string argument, so
 
      (string-length "abc")
 
 is a procedure invocation whose result is the numeric value 3.
 
    Each of the parameters in a procedure invocation can itself be any
 Scheme expression.  Since a procedure invocation is itself a type of
 expression, we can put these two examples together to get
 
      (string-length (string-append "/home" "/" "andrew"))
 
 -- a procedure invocation whose result is the numeric value 12.
 
    (You may be wondering what happens if the two examples are combined
 the other way round.  If we do this, we can make a procedure invocation
 expression that is _syntactically_ correct:
 
      (string-append "/home" (string-length "abc"))
 
 but when this expression is executed, it will cause an error, because
 the result of `(string-length "abc")' is a numeric value, and
 `string-append' is not designed to accept a numeric value as one of its
 arguments.)
 
Info Catalog (guile.info.gz) Procedures as Values (guile.info.gz) About Procedures (guile.info.gz) Creating a Procedure
automatically generated byinfo2html