Back to index

plt-scheme  4.2.1
idmodule.c
Go to the documentation of this file.
00001 /*
00002   Extension that declares a module.
00003   The extension is equivalent to Scheme source of them form:
00004     (module idmodule mzscheme
00005       (define (identity x) x)
00006       (provide identity))
00007 */
00008 
00009 #include "escheme.h"
00010 
00011 static Scheme_Object *id(int argc, Scheme_Object **argv)
00012 {
00013   return argv[0];
00014 }
00015 
00016 Scheme_Object *scheme_reload(Scheme_Env *env)
00017 {
00018   Scheme_Env *menv;
00019   Scheme_Object *proc;
00020 
00021   menv = scheme_primitive_module(scheme_intern_symbol("idmodule"),
00022                              env);
00023 
00024   proc = scheme_make_prim_w_arity(id, "identity", 1, 1);
00025 
00026   /* All added names are automatically exported by the module: */
00027   scheme_add_global("identity", proc, menv);
00028 
00029   scheme_finish_primitive_module(menv);
00030 
00031   return scheme_void;
00032 }
00033 
00034 Scheme_Object *scheme_initialize(Scheme_Env *env)
00035 {
00036   /* First load is same as every load: */
00037   return scheme_reload(env);
00038 }
00039 
00040 Scheme_Object *scheme_module_name()
00041 {
00042   /* This extension defines a module named `idmodule': */
00043   return scheme_intern_symbol("idmodule");
00044 }