This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
guile environment patch
- To: guile@cygnus.com
- Subject: guile environment patch
- From: Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE>
- Date: Tue, 6 Jul 1999 20:36:31 GMT
- Cc: jimb@red-bean.com, djurfeldt@nada.kth.se
the following two patches implement first class top-level environments
as described by Jim Blandy in his environment proposal
(http://www.gnu.org/software/guile/docs/env.html) and a simple module
system on top of them (no documentation yet).
environments:
ftp://ftp.tfh-berlin.de/pub/incoming/guile-environment.patch.gz
module system:
ftp://ftp.tfh-berlin.de/pub/incoming/guile-environment-test.patch.gz
Changelog entry:
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c chars.c,
continuations.c, debug.c, dynl.c, dynwind.c eq.c, eval.c,
evalext.c, feature.c, filesys.c, fluids.c, fports.c, gc.c,
gdbint.c, gsubr.c, guardians.c, hash.c, hashtab.c, init.c,
ioext.c, iselect.c, keywords.c, list.c, load.c, macros.c,
mallocs.c, net_db.c, numbers.c, objects.c, objprop.c, options.c,
pairs.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, random.c, read.c, readline.c, regex-posix.c, root.c,
scmsigs.c, script.c, simposc, socket.c, sort.c, stackchk.c,
stacks.c, stime.c, strings.c, strop.c, strorder.c, strports.c,
struct.c, symbols.c, tag.c, threads.c, throw.c, unif.c,
vectors.c, version.c, vports.c, weaks.c:
changed `void scm_init_<name>()' to `SCM scm_init_<name>(env)'.
All init functions take an environment argument and return
SCM_UNSPECIFIED. For example `scm_init_struct (scm_root_environment)'.
* async.c, backtrace.c, debug.c, feature.c, filesys.c, fports.c,
gh_funcs.c, gsubr.c, load.c, macros.c, net_db.c, objects.c,
ports.c, posix.c, procs.c, read.c, readline.c, regex-posix.c,
root.c, scmsigs.c, script.c, snarf.h, socket.c, srcprop.c,
cpp_cnvt.awk, stime.c, struct.c: changed scm_sysintern() to
scm_environment_intern(env, <string>, <value>)
* debug.c removed procedures make-gloc and gloc?
macro scm_procedure_environment returns the current environment
for tc7_cclo
environment argument to scm_memcons is now required
changed SCM_CAR(scm_sysintern(...)) to
scm_permanent_object (SCM_CAR (scm_intern ("<name>")))
* dynl.c :
removed module registry, struct moddata, scm_register_module_xxx(),
scm_registered_modules(), scm_clear_registered_modules())
scm_dynamic_call() takes an environment as its third argument which
is passed on to the init function
* eval.c :
Convention: ENVIRONMENT names environment smobs
ENV names environments which have the following structure:
(environment-smob . local-alist)
Macros EVALCELLCAR, EVALCAR, SIDEVAL take an environment as 2nd
argument
Macro EXTEND_ENV turned into a function that cons'es a new
(environment-smob . local-alist) pair
scm_ilookup(), scm_lookupcar(), scm_lookupcar1(), scm_unmemocar(),
scm_ceval(), scm_unmemocopy(): environment argument is a pair
(environment-smob . local-alist)
lookupcar1(): removed top_thunk, changed scm_sym2vcell to
SCM_ENVIRONMENT_CELL(), memoization is done through
scm_eval_environment_memoize_cell_internal()
scm_unmemocar(): unmemoize gloc via
eval_environment_update_memoized()
scm_m_define, unmemocopy, scm_ceval: changed SCM_TOP_LEVEL(env) to
SCM_TOP_LEVEL_ENVP (env)
scm_m_define(): scm_sym2vcell(...) changed to
SCM_ENVIRONMENT_DEFINE()
scm_ceval(): all environment manipulations changed to
{
SCM local_env = SCM_CDR (env);
<do something with local_env>
}
scm_eval_3() : removed scm_system_transformer
scm_eval(...) -> scm_eval(..., env) env must be an environment
smob
scm_eval_x(...) dto.
* evalext.c turned scm_defined_p (defined?) into syntax. Symbol
is looked up in the local environment, the environment-smob and
all its ancestors.
scm_make_named_hook(...) -> scm_make_named_hook(..., env)
* gc.c scm_gc_mark() msymbols don't have slots anymore.
scm_must_malloc(), scm_must_realloc(), scm_must_free():
changed char* to void*
scm_init_storage(): removed scm_symhash
* gh.h, gh_*.c
gh_eval_str_*(...) -> gh_eval_str_*(..., env)
gh_eval_file_* dto.
gh_load dto.
gh_new_procedure* dto.
gh_define dto.
disabled gh_lookup() and gh_module_lookup() which aren't implemented
* gsubr.c : scm_make_gsubr(...) -> scm_make_gsubr(..., env)
* guardians.c : scm_init_guardian(): create "guardian" subr in
the current env.
* init.c : start_stack(): takes environment as first argument,
removed scm_top_level_lookup_closure_var and
scm_system_transformer
scm_init_standard_ports(): added environment parameter
scm_load_startup_files(): load boot_9.scm and init.scm into
scm_root_environment
scm_boot_guile():
scm_init_environments() creates scm_root_environment
scm_init_root() ... scm_init_script(): changed to scm_init_*(env)
turned scm_init_regex_posix(), .., scm_init_random() into
c modules
* keywords.c
changed scm_sym2ovcell_soft(symbol, scm_keyword_obarray) into
SCM_ENVIRONMENT_CELL(scm_keyword_environment, symbol, 1)
changed SCM_SETCDR (scm_sym2ovcell_soft(symbol ...), keyword)
to SCM_ENVIRONMENT_DEFINE (scm_keyword_environment, symbol, keyword)
* libguile.h : removed variable.h
* load.c : load(): changed argument to
&struct load_data{ SCM port; SCM env; };
primitive_load(): -> primitive_load(..., env)
scm_init_load_path(): dto.
scm_primitive_load_path() : dto.
scm_primitive_load() : dto.
scm_read_and_eval_x() : 2 optional arguments: port and env. env
defaults to interaction-environment, not the current environment!!
Guile has no idea what (the-environment) is unless you explicitly
pass it as an argument.
* macros.c scm_make_synt () -> scm_make_synt (..., env);
* net_db.c, options.c, posix.c, regex-posix.c :
scm_sysintern(...) -> scm_environment_intern(env,...)
* procs.c :
scm_make_subr_opt(...) -> scm_make_subr_opt(..., env)
scm_make_subr(...): -> scm_make_subr(..., env):
* read.c : scm_lreadr(); removed length argument to scm_intern()
* root.c : removed scm_top_level_lookup_closure_var and
system_transformer from scm_root_state
moved initialization of most-positive-fixnum, most-negative-fixnum,
bignum-radix from scm_init_storage() to scm_init_root()
* root.h: changed scm_keyword_obarray to scm_keyword_environment.
The keyword environment is a finite-environment and maps keyword
symbols to values.
changed sym_symhash to scm_root_environment. The root-environment
is an eval-environment.
added scm_c_module_registry. A finite-environment which maps
module symbols like 'ice-9/posix to values of type scm_tc7_subr_1
(see init.c).
added scm_interaction_environment. According to r5rs this is a
global variable that points to the environment in which the user
*types* commands. The r5rs procedure load evaluates expressions in
this environment. Note that this may lead to confusion if the load
procedure is used whithin a script where (interaction-environment)
is not equal (the-environment). So it may be better to use
scm_primitive_load() instead.
* script : scm_compile_shell_switches(): evaluate "-c" expressions
in scm_root_environment
when interactive: load "ice-9/modules.scm" into scm_root_environment
and (go (access (ice-9 guile)))
* snarf.h : Makros SCM_PROC and SCM_SYNT defined to
`scm_make_gsubr (RANAME, REQ, OPT, VAR, (SCM (*)()) CFN, env)'
where env must be supplied by the scm_init_*() function.
Makros SCM_VCELL, SCM_GLOBAL_VCELL, SCM_VCELL_INIT,
SCM_GLOBAL_VCELL_INIT create bindings in the environment env,
where env must be a local variable of the enclosing
scm_init_*() function. init_val defaults to SCM_BOOL_F.
Note that it is an error to set the value of an environment binding
to SCM_UNSPECIFIED or SCM_UNDEFINED! The following would have
strange side effects: scm_environment_define(env, sym, SCM_UNDEFINED)
If you do that, environment-bound? will tell you that sym is bound
but environment-cell and environment-fold will tell you something
differend.
* stacks.c get_applybody(): replaced lookup for symbol
`scm_sym_apply' by value `scm_i_apply'
* strports.c scm_eval_0str(), scm_eval_string(): added required
environment parameter
* struct.c scm_make_struct_layout(): changed
SCM_CAR(scm_intern_obarray(...)) to scm_permanent_object (SCM_CAR
(scm_intern (...)))
* symbols.c removed scm_sym2vcell(), scm_sym2ovcell(),
scm_sym2ovcell_soft(), scm_intern_obarray_soft(),
scm_intern_obarray(), scm_intern0(),
scm_sysintern_0_no_module_lookup(),
scm_can_use_top_level_lookup_closure_var, scm_sysintern(),
scm_sysintern0(), scm_symbol_value0(), scm_symbol_value(),
scm_string_to_obarray_symbol(), scm_intern_symbol(),
scm_unintern_symbol(), scm_symbol_binding(),
scm_symbol_internec(), scm_symbol_bound_p(), scm_symbol_set_x(),
msymbolize(), scm_symbol_fref(), scm_symbol_pref(),
scm_symbol_fset_x(), scm_symbol_pset_x(), scm_symbol_hash(),
copy_and_prune_obarray(), scm_builtin_bindings(),
scm_builtin_weak_bindings(), scm_symhash.
changed scm_intern(name, len) to scm_intern(name)
changed scm_gensym (name, obarray) to scm_gensym (name)
* symbols.h
removed all slots from msymbols (In the future msymbols
can go away completely).
ssymbols and msymbols now carry their hash value at position
(* ((SCM *)SCM_CHARS(x) - 1)))
added macros SCM_SYMBOL_HASH(sym) and SCM_HASHCODE(sym) to
access a symbol's hash value (both macros do the same but
SCM_HASHCODE() is easier to remember :>)
* _scm.h: added #include "environments.h" as scm_environment_intern()
(the replacement for scm_sysintern()) is used throughout the system.
* Makefile.am: removed variables.[chx], removed kw.h, added
environments.[ch]
Jost