Back to index

plt-scheme  4.2.1
Functions
makeadder.c File Reference
#include "escheme.h"

Go to the source code of this file.

Functions

static Scheme_Objectsch_inner (void *closure_data, int argc, Scheme_Object **argv)
static Scheme_Objectsch_make_adder (int argc, Scheme_Object **argv)
Scheme_Objectscheme_reload (Scheme_Env *env)
Scheme_Objectscheme_initialize (Scheme_Env *env)
Scheme_Objectscheme_module_name ()

Function Documentation

static Scheme_Object* sch_inner ( void closure_data,
int  argc,
Scheme_Object **  argv 
) [static]

Definition at line 15 of file makeadder.c.

{
  /* We only close over one value, so our closure data reprsentation
     is just thaht value: */
  Scheme_Object *n = (Scheme_Object *)closure_data;
  Scheme_Object *plus;
  Scheme_Object *a[2];

  plus = scheme_lookup_global(scheme_intern_symbol("+"), 
                           scheme_get_env(NULL));

  /* return the result of summing m and n: */
  a[0] = n;
  a[1] = argv[0]; /* m */
  return _scheme_apply(plus, 2, a); 

  /* Actually, that's not quite right. In the Scheme code, (+ m n) is
     a tail call. The following would be better:
     return _scheme_tail_apply(plus, 2, a); */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Scheme_Object* sch_make_adder ( int  argc,
Scheme_Object **  argv 
) [static]

Definition at line 36 of file makeadder.c.

{
  return scheme_make_closed_prim_w_arity(sch_inner,
                                    argv[0],
                                    "adder",
                                    1, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file makeadder.c.

{
  /* First load is same as every load: */
  return scheme_reload(env);
}

Here is the call graph for this function:

Definition at line 61 of file makeadder.c.

{
  /* This extension doesn't define a module: */
  return scheme_false;
}

Definition at line 44 of file makeadder.c.

{
  scheme_add_global("make-adder",
                  scheme_make_prim_w_arity(sch_make_adder,
                                        "make-adder", 
                                        1, 1),
                  env);

  return scheme_void;
}

Here is the call graph for this function: