As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.' It does take up
space though! For that reason, we remove it here from our C files.
* libguile/deprecated.h (SCM_TOP_LEVEL_LOOKUP_CLOSURE):
* libguile/deprecated.c (scm_lookup_closure_module):
(scm_module_lookup_closure):
(scm_current_module_lookup_closure): Deprecate this part of the eval
closure interface. It was unused internally, after the scm_sym2var
refactor.
* libguile/eval.h:
* libguile/modules.c:
* libguile/modules.h: Remove deprecated code.
* libguile/goops.c (scm_ensure_accessor): Use scm_module_variable
instead of calling the lookup closure. However I'm not sure that this
code is used at all.
* libguile/eval.h:
* libguile/eval.c (scm_call_n): New function, applies a function to an
array of args.
* libguile/hooks.h:
* libguile/hooks.c (scm_c_run_hookn): New function, runs a hook with an
array of args.
* libguile/debug.c (scm_procedure_name): Remove a SCM_CLOSUREP case and
some dead code.
(scm_procedure_module): Remove. This was introduced a few months ago
for the hygienic expander, but now it is no longer needed, as the
expander keeps track of this information itself.
* libguile/debug.h: Remove scm_procedure_module.
* libguile/eval.c: Instead of using tc3 closures, define a "boot
closure" applicable smob type, and represent closures with that. The
advantage is that after eval.scm is compiled, boot closures take up no
address space (besides a smob number) in the runtime, and require no
special cases in procedure dispatch.
* libguile/eval.h: Remove the internal functions scm_i_call_closure_0
and scm_closure_apply, and the public function scm_closure.
* libguile/gc.c (scm_storage_prehistory): No tc3_closure displacement
registration.
(scm_i_tag_name): Remove closure case, and a dead cclo case.
* libguile/vm.c (apply_foreign):
* libguile/print.c (iprin1):
* libguile/procs.c (scm_procedure_p, scm_procedure_documentation);
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of): Remove tc3_closure/tcs_closure cases.
* libguile/hash.c (scm_hasher):
* libguile/hooks.c (scm_add_hook_x): Use new scm_i_procedure_arity.
* libguile/macros.c (macro_print): Print all macros using the same code.
(scm_macro_transformer): Return any procedure, not just programs.
* libguile/procprop.h:
* libguile/procprop.c (scm_i_procedure_arity): Instead of returning a
list that the caller has to parse, have the same prototype as
scm_i_program_arity. An incompatible change, but it's an internal
function anyway.
(scm_procedure_properties, scm_set_procedure_properties)
(scm_procedure_property, scm_set_procedure_property): Remove closure
cases, and use scm_i_program_arity for arity.
* libguile/procs.h (SCM_CLOSUREP, SCM_CLOSCAR, SCM_CODE)
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS)
(SCM_CLOSURE_BODY, SCM_PROCPROPS, SCM_SETPROCPROPS, SCM_ENV)
(SCM_TOP_LEVEL): Remove these macros that pertain to boot closures
only. Only eval.c should know abut boot closures.
* libguile/procs.c (scm_closure_p): Remove this function. There is a
simple stub in deprecated.scm now.
(scm_thunk_p): Use scm_i_program_arity.
* libguile/tags.h (scm_tc3_closure): Remove. Yay, another tc3 to play
with!
(scm_tcs_closures): Remove.
* libguile/validate.h (SCM_VALIDATE_CLOSURE): Remove.
* module/ice-9/deprecated.scm (closure?): Add stub.
* module/ice-9/documentation.scm (object-documentation)
* module/ice-9/session.scm (help-doc, arity)
* module/oop/goops.scm (compute-getters-n-setters)
* module/oop/goops/describe.scm (describe)
* module/system/repl/describe.scm (display-object, display-type):
Remove calls to closure?.
* libguile/eval.h:
* libguile/eval.c (scm_closure_apply): New function, applies a closure.
Won't be necessary in the future, but for now here it is, with
internal linkage.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_gsubr_apply_array): New function, applies a
gsubr to an array of values, potentially extending that array for
optional arguments and rest arguments and such.
* libguile/vm.c (apply_foreign): New function, applies a foreign
function to arguments on the stack, in place.
* libguile/vm-i-system.c (call): Add a case for procedures-with-setters
(will go away when they are applicable structs). Instead of calling
the evaluator for foreign functions, call apply_foreign.
* libguile/eval.c: So, ladies & gents, a new evaluator. It's similar to
the old one, in that we memoize and then evaluate, but in this
incarnation, memoization of an expression happens before evaluation,
not lazily as the expression is evaluated. This makes the evaluation
itself much cleaner, in addition to being threadsafe. In addition,
since this C evaluator will in the future just serve to bootstrap the
Scheme evaluator, we don't have to pay much concern for debugging
conveniences. So the environment is just a list of values, and the
memoizer pre-computes where it's going to find each individual value
in the environment.
Interface changes are commented below, with eval.h.
(scm_evaluator_traps): No need to reset the debug mode after rnning te
traps thing. But really, the whole traps system needs some love.
* libguile/memoize.h:
* libguile/memoize.c: New memoizer, which runs before evaluation,
checking all syntax before evaluation begins. Significantly, no
debugging information is left for lexical variables, which is not so
great for interactive debugging; perhaps we should change this to have
a var list in the future as per the classic interpreters. But it's
quite fast, and the resulting code is quite good. Also note that it
doesn't produce ilocs, memoized code is a smob whose type is in the
first word of the smob itself.
* libguile/eval.h (scm_sym_and, scm_sym_begin, scm_sym_case)
(scm_sym_cond, scm_sym_define, scm_sym_do, scm_sym_if, scm_sym_lambda)
(scm_sym_let, scm_sym_letstar, scm_sym_letrec, scm_sym_quote)
(scm_sym_quasiquote, scm_sym_unquote, scm_sym_uq_splicing, scm_sym_at)
(scm_sym_atat, scm_sym_atapply, scm_sym_atcall_cc)
(scm_sym_at_call_with_values, scm_sym_delay, scm_sym_eval_when)
(scm_sym_arrow, scm_sym_else, scm_sym_apply, scm_sym_set_x)
(scm_sym_args): Remove public declaration of these symbols.
(scm_ilookup, scm_lookupcar, scm_eval_car, scm_eval_body)
(scm_eval_args, scm_i_eval_x, scm_i_eval): Remove public declaration
of these functions.
(scm_ceval, scm_deval, scm_ceval_ptr): Remove declarations of these
deprecated functions.
(scm_i_print_iloc, scm_i_print_isym, scm_i_unmemocopy_expr)
(scm_i_unmemocopy_body): Remove declarations of these internal
functions.
(scm_primitive_eval_x, scm_eval_x): Redefine as macros for their less
destructive siblings.
* libguile/Makefile.am: Add memoize.[ch] to the build.
* libguile/debug.h (scm_debug_mode_p, scm_check_entry_p)
(scm_check_apply_p, scm_check_exit_p, scm_check_memoize_p)
(scm_debug_eframe_size): Remove these vars that were tied to the old
evaluator's execution model.
(SCM_RESET_DEBUG_MODE): Remove, no more need for this.
(SCM_MEMOIZEDP, SCM_MEMOIZED_EXP, SCM_MEMOIZED_ENV): Remove macros
referring to old memoized code representation.
(scm_local_eval, scm_procedure_environment, scm_memoized_environment)
(scm_make_memoized, scm_memoized_p): Remove functions operating on old
memoized code representation.
(scm_memcons, scm_mem_to_proc, scm_proc_to_mem): Remove debug-only
code for old evaluator.
* libguile/debug.c: Remove code to correspond with debug.h removals.
(scm_debug_options): No need to set the debug mode or frame limit
here, as we don't have C stack limits any more. Perhaps this is a bug,
but as long as we can compile eval.scm, we should be fine.
* libguile/init.c (scm_i_init_guile): Init memoize.c.
* libguile/modules.c (scm_top_level_env, scm_env_top_level)
(scm_env_module, scm_system_module_env_p): Remove these functions.
* libguile/print.c (iprin1): No more need to handle isyms. Adapt to new
form of interpreted procedures.
* libguile/procprop.c (scm_i_procedure_arity): Adapt to new form of
interpreted procedures.
* libguile/procs.c (scm_thunk_p): Adapt to new form of interpreted
procedures.
* libguile/procs.h (SCM_CLOSURE_FORMALS): Removed, this exists no more.
(SCM_CLOSURE_NUM_REQUIRED_ARGS, SCM_CLOSURE_HAS_REST_ARGS): New
accessors.
* libguile/srcprop.c (scm_source_properties, scm_source_property)
(scm_set_source_property_x): Remove special cases for memoized code.
* libguile/stacks.c (read_frame): Remove a source-property case for
interpreted code.
(NEXT_FRAME): Remove a case that I don't fully understand, that seems
to be designed to skip over apply frames. Will be obsolete in the
futures.
(read_frames): Default source value for interpreted frames to #f.
(narrow_stack): Don't pay attention to the system_module thing.
* libguile/tags.h: Remove isyms and ilocs. Whee!
* libguile/validate.h (SCM_VALIDATE_MEMOIZED): Fix to use the new
MEMOIZED_P formulation.
* module/ice-9/psyntax-pp.scm (do, quasiquote, case): Adapt for these no
longer being primitive macros.
* module/ice-9/boot-9.scm: Whitespace change, but just a poke to force a
rebuild due to and/or/cond/... not being primitives any more.
* module/ice-9/deprecated.scm (unmemoize-expr): Deprecate, it's
unmemoize-expression now.
* test-suite/tests/eval.test ("define set procedure-name"): XFAIL a
couple of tests here; I don't know what to do about them. I reckon the
expander should ensure that defined values are named.
* test-suite/tests/chars.test ("basic char handling"): Fix expected
exception when trying to apply a char.
* libguile.h:
* libguile/Makefile.am
* libguile/init.c (scm_i_init_guile): Add trees.[ch] to the build.
* libguile/eval.c:
* libguile/eval.h: Remove scm_copy_tree and scm_cons_source...
* libguile/trees.h:
* libguile/trees.c:
* libguile/srcprop.h:
* libguile/srcprop.c: ... factoring them out here and here,
respectively.
* test-suite/tests/eval.test ("memoization"): Change expected exception
for circular data structures, given new copy-tree location.
* libguile/eval.h:
* libguile/eval.c (scm_m_eval_when): Define a cheap eval-when, used
before syncase has booted.
* module/Makefile.am: Reorder to put (system vm) and (system repl)
modules after the compiler, as they are not needed at runtime.
* module/ice-9/boot-9.scm: Move the eval-when earlier, to be the first
thing -- so when we recompile Guile we do so all in the '(guile)
module, not '(guile-user).
* module/ice-9/compile-psyntax.scm: Rewrite to assume that psyntax.scm
will eval-when to set its module, etc. Have everything in a let --
otherwise the `format' call is in (guile), but `target' was defined
in (guile-user). Also, write in an eval-when to the expanded file.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/networking.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/r4rs.scm: Sprinkles of eval-when, for flavor.
* libguile/eval.h:
* libguile/eval.c (error_unbound_variable, error_defined_variable):
Move these prototypes up earlier.
(scm_m_at, scm_m_atat): New functions, provide the @ and @@
functionality. Moved here from defmacros because they are
"special", inasmuch as syncase doesn't really understand them in
interpreted code.
* module/ice-9/boot-9.scm (@, @@): Don't define as defmacros, as
defmacros have to actually return source now.
* libguile/eval.h:
* libguile/eval.c (scm_make_promise): Rename from `scm_makprom', and
export as the scheme procedure, `make-promise'.
* libguile/eval.i.c (CEVAL): s/makprom/make_promise/.
scm_i_unmemoize_expr for unmemoizing a memoized object holding a
single memoized expression.
* debug.c (memoized_print): Don't try to unmemoize the memoized
object, since we can't know whether it holds a single expression
or a body.
(scm_mem_to_proc): Removed check for lambda expression, since it
was moot anyway. Whoever uses these functions for debugging
purposes should know what they do: Creating invalid memoized code
will cause crashes, independent of whether this check is present
or not.
(scm_proc_to_mem): Take the closure's code as it is and don't
append a SCM_IM_LAMBDA isym. To allow easier debugging, the
memoized code should not be modified.
* debug.[ch] (scm_unmemoize, scm_i_unmemoize_expr): Removed
scm_unmemoize from public use, but made scm_i_unmemoize_expr
available as a guile internal function instead. However,
scm_i_unmemoize_expr will only work on memoized objects that hold
a single memoized expression. It won't work with bodies.
* debug.c (scm_procedure_source), macros.c (macro_print), print.c
(scm_iprin1): Call scm_i_unmemocopy_body for unmemoizing a body,
i. e. a list of expressions.
* eval.c (unmemoize_exprs): Drop internal body markers from the
output during unmemoization.
* eval.[ch] (scm_unmemocopy, scm_i_unmemocopy_expr,
scm_i_unmemocopy_body): Removed scm_unmemocopy from public use,
but made scm_i_unmemocopy_expr and scm_i_unmemocopy_body available
as guile internal functions instead. scm_i_unmemoize_expr will
only work on a single memoized expression, while
scm_i_unmemocopy_body will only work on bodies.
* deprecated.h (SCM_IFRINC, SCM_ICDR, SCM_IFRAME, SCM_IDIST,
SCM_ICDRP), eval.c (SCM_IFRINC, SCM_ICDR, SCM_IFRAME, SCM_IDIST,
SCM_ICDRP), eval.h (SCM_ICDR, SCM_IFRINC, SCM_IFRAME, SCM_IDIST,
SCM_ICDRP): Deprecated and added to deprecated.h. Moved from
eval.h to eval.c.
* deprecated.c (scm_isymnames), deprecated.h (scm_isymnames,
SCM_ISYMNUM, SCM_ISYMCHARS), eval.c (SCM_ISYMNUM, isymnames,
scm_unmemocopy, CEVAL), print.c (scm_isymnames), tags.h
(SCM_ISYMNUM, scm_isymnames, SCM_ISYMCHARS): Deprecated
scm_isymnames, SCM_ISYMNUM and SCM_ISYMCHARS and added to
deprecated.[hc]. Moved scm_isymnames from print.c to eval.c and
renamed to isymnames. Moved SCM_ISYMNUM from tags.h to eval.c and
renamed to ISYMNUM.
* eval.c (scm_i_print_iloc, scm_i_print_isym), eval.h
(scm_i_print_iloc, scm_i_print_isym), print.c (scm_iprin1):
Extracted printing of ilocs and isyms to guile internal functions
scm_i_print_iloc, scm_i_print_isym of eval.c.
SCM_DEBUGGINGP:
* debug.h (scm_debug_mode_p, scm_debug_mode, SCM_DEBUGGINGP),
eval.c (scm_debug_mode_p): Deprecated scm_debug_mode and
SCM_DEBUGGINGP. Provided scm_debug_mode_p instead, to have one
single interface that also matches the naming conventions.
Probably scm_debug_mode_p should be part of the private interface
anyway.
* debug.h (scm_debug_mode_p), backtrace.c (display_error_body),
eval.c (SCM_APPLY, scm_trampoline_0, scm_trampoline_1,
scm_trampoline_2): Change uses of scm_debug_mode or SCM_DEBUGGINGP
to scm_debug_mode_p.
Deprecate direct access to scm_ceval, scm_deval and scm_ceval_ptr:
* eval.h (scm_ceval, scm_deval, scm_ceval_ptr), debug.h
(scm_ceval_ptr): Deprecated. Moved declaration of scm_ceval_ptr
from debug.h to eval.h.
* debug.h (SCM_RESET_DEBUG_MODE): Don't access scm_ceval_ptr any
more, just leave it with setting scm_debug_mode_p, which is
equivalent for practical purposes.
* deprecated.h (SCM_XEVAL, SCM_XEVALCAR): Call scm_i_eval_x
instead of *scm_ceval_ptr. Leave all evaluating to scm_i_eval_x.
* gdbint.c (gdb_eval): Call scm_i_eval_x instead of scm_ceval.
* eval.c (ceval, deval, scm_ceval, scm_deval): Made scm_ceval
static and renamed it to ceval throughout. Provide a new exported
but deprecated function scm_ceval as a wrapper for backwards
compatibility. The same is done for the deval/scm_deval pair of
functions.
* eval.c (CEVAL, SCM_CEVAL): Renamed SCM_CEVAL to CEVAL
throughout. Defined CEVAL to ceval or deval, based on compilation
phase.
* eval.c (SCM_XEVAL, SCM_XEVALCAR): Dispatch on scm_debug_mode_p
to ceval and deval instead of calling *scm_ceval_ptr.
* eval.c (dispatching_eval): New deprecated static function.
* eval.c (scm_ceval_ptr): Initialized to dispatching_eval in order
to emulate its old behaviour as closely as possible.
Change the evaluator such that only expressions for which pair? is
true are passed to CEVAL, and such that all other expressions are
evaluated outside of CEVAL:
* eval.c (EVAL): New, provided in analogy to EVALCAR. Evaluate an
expression that is assumed to be memoized already. All but
expressions of the form '(<form> <form> ...)' are evaluated inline
without calling an evaluator.
* eval.c (SCM_XEVAL, SCM_XEVALCAR, EVALCAR): Evaluate all but
expressions of the form '(<form> <form> ...)' inline without
calling an evaluator.
* eval.c (scm_i_eval_x, scm_i_eval, scm_ceval, scm_deval): Handle
the special case of unmemoized symbols passed on the top level.
* eval.c (CEVAL): Change calls to CEVAL to EVAL, except where it
is known that the expression passed to CEVAL is of the form
'(<form> <form> ...)'. Remove handling of the tc7-objects, since
now it is known that the input expression of CEVAL is a pair.
(lookup_global_symbol, lookup_symbol): New static functions.
(s_test, s_bindings, s_duplicate_bindings, s_variable): Removed.
(try_macro_lookup, literal_p): Use lookup_symbol instead of
creating a temporary pair for scm_lookupcar.
(scm_unmemocar, unmemocar): Renamed scm_unmemocar to unmemocar,
created deprecated wrapper function scm_unmemocar.
(SCM_VALIDATE_NON_EMPTY_COMBINATION, scm_sym_else,
scm_sym_unquote, scm_sym_uq_splicing, scm_sym_enter_frame,
scm_sym_apply_frame, scm_sym_exit_frame, scm_sym_trace, f_apply,
undefineds, sym_three_question_marks): Moved around without
modifications.
* eval.c, eval.h (scm_macroexp, scm_unmemocar): Deprecated.
public use of scm_m_expand_body in eval.h. In eval.c, renamed
scm_m_expand_body to m_expand_body and made it static. Added
deprecated wrapper scm_m_expand_body.
(scm_eval_body, SCM_CEVAL, SCM_APPLY): Use m_expand_body instead
of scm_m_expand_body.
SCM_DEBUG_DEBUGGING_SUPPORT): Renamed macro
SCM_DEBUG_DEBUGGER_SUPPORT to SCM_DEBUG_DEBUGGING_SUPPORT and
generalized it to apply not only to C level functions but also to
scheme level functions.
* debug.c, debug.h, eval.c (make-iloc, scm_make_iloc, iloc?,
scm_iloc_p, dbg-make-iloc, scm_dbg_make_iloc, dbg-iloc?,
scm_dbg_iloc_p): Moved functions scm_make_iloc, scm_iloc_p to
eval.c, made them available under SCM_DEBUG_DEBUGGING_SUPPORT == 1
only and renamed them to scm_dbg_make_iloc, scm_dbg_iloc_p,
respectively.
* deprecated.h, eval.c, eval.h (SCM_ILOC00, SCM_IDINC,
SCM_IDSTMSK): Deprecated. The macro definitions are moved from
eval.h into eval.c and a copy is placed into deprecated.h.
* eval.c, eval.h (SCM_MAKE_ILOC): Removed from eval.h and placed
into eval.c. This definition was not part of the API in any
officially released version of guile and thus does not need to go
through a phase of deprecation.
scm_s_expression, scm_s_test, scm_s_body, scm_s_bindings,
scm_s_variable, scm_s_clauses, scm_s_formals. In eval.c the
definitions are make static and renamed from scm_s_xxx to s_xxx.
In deprecated.c the original definitions are copied.
* deprecated.h, eval.c, eval: Deprecated SCM_EVALIM2, SCM_EVALIM,
SCM_XEVAL and SCM_XEVALCAR. The macro definitions are moved from
eval.h into eval.c and a copy (slightly modified to work in user
code) is placed into deprecated.h.
* eval.c: Use the local static s_xxx definitions instead of the
scm_s_xxx definitions throughout.
scm_m_atslot_set_x, scm_m_atdispatch): Move the declarations and
definitions of the special goops memoizers from goops.[ch] to
eval.[ch]. Hmm... it seems that scm_m_atdispatch is not used
throughout guile.
scm_m_generalized_set_x, scm_init_evalext): Move the declaration
and definition of the memoizer for the generalized set! macro from
evalext.[ch] to eval.[ch]. Use the SCM_SYNTAX snarfer macro to
define the macro object.
* eval.c, eval.h (s_set_x, scm_s_set_x, scm_m_set_x,
scm_m_generalized_set_x): Since now scm_s_set_x is only used in
eval.c, it is made static and renamed to s_set_x.
* evalext.c (scm_defined_p, scm_m_undefine): Prefer !SCM_<foo>
over SCM_N<foo>.
scm_init_eval): Made scm_undefineds static in eval.c, renamed it
to undefineds and registered the object as a permanent object.
* eval.c, eval.h (scm_f_apply, scm_init_eval): Made scm_f_apply
static in eval.c, renamed it to f_apply and registered the object
as a permanent object.
Simply lock a thread C API recursive mutex.
(SCM_NONREC_CRITICAL_SECTION_START,
SCM_NONREC_CRITICAL_SECTION_END, SCM_REC_CRITICAL_SECTION_START,
SCM_REC_CRITICAL_SECTION_END): Removed.
* eval.c: Replaced SOURCE_SECTION_START / SOURCE_SECTION_END with
direct calls to scm_rec_mutex_lock / unlock around the three calls
to scm_m_expand_body.
* eval.c, eval.h (promise_free): New function.
(scm_force): Rewritten; Now thread-safe; Removed
SCM_DEFER/ALLOW_INTS.
* pthread-threads.h: Added partially implemented plugin interface
for recursive mutexes. These are, for now, only intended to be
used internally within the Guile implementation.
* pthread-threads.c: New file.
* threads.c: Conditionally #include "pthread-threads.c".
* eval.c, eval.h (scm_makprom, scm_force): Rewritten to be
thread-safe;
* snarf.h (SCM_MUTEX, SCM_GLOBAL_MUTEX, SCM_REC_MUTEX,
SCM_GLOBAL_REC_MUTEX): New macros.
* eval.c, threads.c, threads.h, snarf.h: Rewrote critical section
macros---use mutexes instead.
* tags.h (SCM_IM_FUTURE): New tag.
* eval.c (scm_m_future): New primitive macro.
(SCM_CEVAL): Support futures.
(unmemocopy): Support unmemoization of futures.
* print.c (scm_isymnames): Name of future isym.