( Subrs

Info Catalog ( Closures ( Non-immediate Datatypes ( Port Data Subrs
 [FIXME: this needs to be further subbed, but texinfo has no subsubsub]
    A subr is a pointer to a C function, packaged up as a Scheme object
 to make it callable by Scheme code.  In addition to the function
 pointer, the subr also contains a pointer to the name of the function,
 and information about the number of arguments accepted by the C
 function, for the sake of error checking.
    There is no single type predicate macro that recognizes subrs, as
 distinct from other kinds of procedures.  The closest thing is
 `scm_procedure_p'; see  Procedures.
  -- Macro: char * SCM_SNAME (X)
      Return the name of the subr X.  The result is undefined if X is
      not a subr.
  -- Function: SCM scm_c_define_gsubr (char *NAME, int REQ, int OPT, int
           REST, SCM (*FUNCTION)())
      Create a new subr object named NAME, based on the C function
      FUNCTION, make it visible to Scheme the value of as a global
      variable named NAME, and return the subr object.
      The subr object accepts REQ required arguments, OPT optional
      arguments, and a REST argument iff REST is non-zero.  The C
      function FUNCTION should accept `REQ + OPT' arguments, or `REQ +
      OPT + 1' arguments if `rest' is non-zero.
      When a subr object is applied, it must be applied to at least REQ
      arguments, or else Guile signals an error.  FUNCTION receives the
      subr's first REQ arguments as its first REQ arguments.  If there
      are fewer than OPT arguments remaining, then FUNCTION receives the
      value `SCM_UNDEFINED' for any missing optional arguments.  If RST
      is non-zero, then any arguments after the first `REQ + OPT' are
      packaged up as a list as passed as FUNCTION's last argument.
      Note that subrs can actually only accept a predefined set of
      combinations of required, optional, and rest arguments.  For
      example, a subr can take one required argument, or one required
      and one optional argument, but a subr can't take one required and
      two optional arguments.  It's bizarre, but that's the way the
      interpreter was written.  If the arguments to `scm_c_define_gsubr'
      do not fit one of the predefined patterns, then
      `scm_c_define_gsubr' will return a compiled closure object instead
      of a subr object.
Info Catalog ( Closures ( Non-immediate Datatypes ( Port Data
automatically generated byinfo2html