* libguile/tags.h (scm_tc7_hashtable): Allocate a tc7 for hashtables.
* libguile/hashtab.h: Adjust macros accordingly.
(scm_i_hashtable_print, scm_i_hashtable_equal_p): New internal
functions.
(scm_hashtab_prehistory): Remove, no more need for this.
* libguile/hashtab.c (scm_hash_fn_remove_x): Fix a longstanding bug.
(make_hash_table): Adapt to the new hash table representation.
* libguile/eq.c (scm_equal_p)
* libguile/evalext.c (scm_self_evaluating_p)
* libguile/print.c (iprin1)
* libguile/gc.c (scm_i_tag_name): Add some tc7_hashtab cases.
* libguile/init.c: Remove unused environments init functions. Remove
call to hashtab_prehistory.
* libguile/goops.h (scm_class_hashtable)
* libguile/goops.c (scm_class_of, create_standard_classes): Have to
make a class for hash tables manually, because they aren't smobs any
more.
* libguile/goops.h (scm_sys_tag_body): Remove declaration of undefined
function.
(SCM_CLASS_CLASS_LAYOUT, scm_si_environment, SCM_N_CLASS_SLOTS)
(scm_class_environment) Remove class environment slot and getter.
* libguile/goops.c (compute_getters_n_setters): Use scm_primitive_eval
to produce the init thunk, instead of scm_i_eval_x; though really we
should be doing this in Scheme.
(scm_basic_basic_make_class, build_class_class_slots)
(create_basic_classes, scm_class_environment): Remove class
environment slot.
(get_slot_value, set_slot_value): Use scm_call_1 instead of evaluator
tricks.
* module/oop/goops.scm: Remove class-environment export, and
environments throughout the file.
* libguile/goops.h (SCM_MCACHE_N_SPECIALIZED)
(SCM_SET_MCACHE_N_SPECIALIZED, SCM_INITIAL_MCACHE_SIZE)
(scm_make_method_cache, scm_memoize_method, scm_mcache_lookup_cmethod)
(scm_mcache_compute_cmethod):
* libguile/goops.c: Remove these procedures which managed the method
cache. There's still a slot there but it's not initialized. The method
cache is no longer necessary.
* module/oop/goops/dispatch.scm (memoize-method!): Change to not take a
"cache" argument.
* libguile/eval.i.c:
* libguile/vm-i-system.c: Remove dispatch via the method cache.
* libguile/eval.i.c (CEVAL, SCM_APPLY): Dispatch applicable structs
before pure generics. In practice what this means is that we never hit
the mcache case, because all pure generics are applicable structs.
We're moving over to having generics dispatch themselves. Also, they
don't prepend the struct as an arg; in order to have that effect, the
user has closures.
* libguile/goops.c (scm_apply_generic, scm_call_generic_0):
(scm_call_generic_1, scm_call_generic_2, scm_call_generic_3): Dispatch
directly to the struct procedures.
(scm_var_make_extended_generic): Remove a duplicate definition for
scm_var_make_extended_generic.
(create_standard_classes): Mark all instances of
<applicable-struct-class> (themselves classes) as applicable classes.
Meaning: generics are now applicable structs.
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT): The hashsets are actually
uw slots -- or at least, making subclasses maps the int slots to be uw
slots
* libguile/vm-i-system.c (call, goto/args, mv-call): Dispatch applicable
structs in the VM.
* module/oop/goops/dispatch.scm (emit-linear-dispatch): Fix bug in the
non-rest cache miss case.
(delayed-compile): Rework to avoid fluids.
(cache-dispatch): Don't call `equal?', it causes bootstrapping
problems with the primitive-generic equal?. Using our own version is
faster anyway.
* libguile/goops.h:
* libguile/goops.c (scm_set_primitive_generic_x): New function, for now
local to the goops module.
* module/oop/goops.scm (equal?): Make sure that when equal? is extended,
that the generic already has a default method.
* libguile/goops.c (scm_class_applicable_struct)
(scm_class_applicable_struct_with_setter)
(scm_class_applicable_struct_class): Rename from
scm_class_entity, scm_class_entity_with_setter, and
scm_class_entity_class.
(scm_class_simple_method): Removed; this abstraction is not used.
(scm_class_foreign_class, scm_class_foreign_object): Remove these,
they are undocumented and unused. They might come back later.
(scm_sys_inherit_magic_x): Simply inherit the vtable flags from the
class's class. Flags are about layout, and it is the class that
determines the layout of the instance.
(scm_basic_basic_make_class): Don't bother setting GOOPS_OR_VALID,
inherit-magic will do that.
(scm_basic_make_class): Inherit magic after setting the layout. Allows
the struct magic checker to do its job.
(scm_accessor_method_slot_definition): Move implementation to Scheme.
Removes the need for the accessor flag.
(scm_sys_allocate_instance): Adapt to scm_i_alloc_struct name change,
and that alloc-struct will handle finalization.
(scm_compute_applicable_methods): Remove accessor check, as it's
unnecessary.
(scm_make): Adapt to new generic slot order, and no more
simple-method.
(create_standard_classes): What was the GF slot "dispatch-procedure"
is now the applicable-struct slot "procedure". No more foreign class,
foreign object, or simple method. Rename <entity> and friends to
<applicable-struct> and friends. No more entity-with-setter -- though
perhaps it will come back too. Instead generic-with-setter is its own
thing.
* libguile/goops.h (SCM_CLASSF_METACLASS): "A goops class that is a
vtable" -- no need for a separate flag.
(SCM_CLASSF_FOREIGN, SCM_CLASSF_SIMPLE_METHOD)
(SCM_CLASSF_ACCESSOR_METHOD): Removed these unused flags.
(SCM_ACCESSORP): Removed.
Renumber generic slots, rename entity classes, and remove the foreign
class, foreign object, and simple method classes.
* libguile/struct.c (scm_i_struct_inherit_vtable_magic): New function,
called when making new vtables.applicable structs
(scm_i_alloc_struct): Remove 8-bit alignment check, as libGC
guarantees this for us. Handle finalizer registration here.
(scm_make_struct): Factor some things to scm_i_alloc_struct and
scm_i_struct_inherit_vtable_magic.
(scm_make_vtable_vtable): Adapt to scm_i_alloc_struct name change.
* libguile/struct.h (scm_i_alloc_struct): Change name from
scm_alloc_struct, and make internal.
* module/oop/goops.scm (oop): Don't declare #:replace <class> et al,
because <class> isn't defined in the core any more.
(accessor-method-slot-definition): Defined in Scheme now.
Remove <foreign-object> methods.
(initialize on <class>): Prep layout before inheriting magic, as in
scm_basic_make_class.
* module/oop/goops/dispatch.scm (delayed-compile)
(memoize-effective-method!): Adapt to 'procedure slot name change.
* libguile/goops.h (scm_si_dispatch_procedure)
(scm_si_effective_methods): Rename the new generics slots to
"effective-methods" and "dispatch-procedure".
(scm_si_generic_setter): Rename this one from "%setter" to "setter",
and it's not a cache -- it's a pointer to the setter, which is also a
generic. I didn't realize that before. It's better this way (like it
always was.)
(SCM_SET_GENERIC_DISPATCH_PROCEDURE)
(SCM_CLEAR_GENERIC_EFFECTIVE_METHODS): New helper macros.
* libguile/goops.c (clear_method_cache): Clear the new dispatch
procedure and the effective methods as well.
(create_standard_classes): Rename slots, and fix the setter slots.
* libguile/goops.c (scm_sys_invalidate_method_cache_x, scm_make)
(create_standard_classes): Remove code-table slot from methods. The
generic cache completely does its job, afaict.
* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_make_procedure):
Renumber slots.
* module/oop/goops.scm (initialize on <method>): No more code-table
slot.
* module/oop/goops/compile.scm: Always "compile" a method, instead of
looking for a hit in an always-empty cache.
* libguile/goops.c (clear_method_cache)
(scm_sys_invalidate_method_cache_x, scm_make)
(create_standard_classes): Remove the used-by method from generics, as
it is not used at all.
* libguile/goops.h: Renumber generic slots.
* module/oop/goops/dispatch.scm (memoize-method!): No more used-by slot.
* libguile/goops.c (create_standard_classes):
* libguile/goops.h *scm_si_applicable_methods, scm_si_effective_method)
(scm_si_applicable_setter_methods, scm_si_effective_setter_method):
Add space for the new form of the generic cache and effective method.
I tried to split this one, and I know it's a bit disruptive, but this
stuff really is one big cobweb. So instead we'll pretend like these are
separate commits, by separating the changelog.
Applicable struct runtime support.
* libguile/debug.c (scm_procedure_source):
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2):
* libguile/eval.i.c (CEVAL):
* libguile/goops.c (scm_class_of):
* libguile/procprop.c (scm_i_procedure_arity):
* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Allow
for applicable structs. Whee!
* libguile/deprecated.h (scm_vtable_index_vtable): Define as a synonym
for scm_vtable_index_self.
(scm_vtable_index_printer): Alias scm_vtable_index_instance_printer.
(scm_struct_i_free): Alias scm_vtable_index_instance_finalize.
(scm_struct_i_flags): Alias scm_vtable_index_flags.
(SCM_STRUCTF_FLAGS): Be a -1 mask, we have a whole word now.
(SCM_SET_VTABLE_DESTRUCTOR): Implement by hand.
Hidden slots.
* libguile/struct.c (scm_make_struct_layout): Add support for "hidden"
fields, writable fields that are not visible to make-struct. This
allows us to add fields to vtables and not break existing make-struct
invocations.
(scm_struct_ref, scm_struct_set_x): Always get struct length from the
vtable. Support hidden fields.
* libguile/goops.c (scm_class_hidden, scm_class_protected_hidden): New
slot classes, to correspond to the new vtable slots.
(scm_sys_prep_layout_x): Turn hidden slots into 'h'.
(build_class_class_slots): Reorder the class slots to account for
vtable fields coming out of negative-land, for name as a vtable slot,
and for hidden fields.
(create_standard_classes): Define <hidden-slot> and
<protected-hidden-slot>.
Clean up struct.h.
* libguile/struct.h: Lay things out cleaner. There are no more hidden
(negative) words. Names are nicer. The exposition is nicer. But the
basics are the same. The incompatibilities are that <vtable> has more
slots now, and that scm_alloc_struct's signature has changed. The
former is ameliorated by the "hidden" slots mentioned before, and the
latter, well, it was always a very internal thing...
(scm_t_struct_finalize): New type, a finalizer function to be run when
instances of a vtable are collected.
(scm_t_struct_free): Removed, structs' data is managed by the GC now,
and not freed by vtable functions.
* libguile/struct.c: (scm_vtable_p): Now we keep flags on
vtable-vtables, so this check is cheaper.
(scm_alloc_struct): No hidden words. Yippee.
(struct_finalizer_trampoline): Entersify.
(scm_make_struct): No need to babysit extra words, though now we have
to babysit flags. Propagate the vtable, applicable, and setter flags
appropriately.
(scm_make_vtable_vtable): Update for new simplicity.
(scm_print_struct): A better printer.
(scm_init_struct): Define <applicable-struct-vtable>, a magical vtable
like CL's funcallable-standard-class. Also define
<applicable-struct-with-setter-vtable>.
Remove foreign object implementation.
* libguile/goops.h:
* libguile/goops.c (scm_make_foreign_object, scm_make_class)
(scm_add_slot, scm_wrap_object, scm_wrap_component): Remove, these
were undocumented and unworking.
Clean up goops.h, a little.
* libguile/goops.h:
* libguile/goops.c: Also clean up.
* module/oop/goops/dispatch.scm (hashset-index): Adapt for new hashset
index.
* libguile/struct.h (scm_struct_i_size): Remove this shared field -- I
mean, the slot is still there, but it's only used for flags.
* libguile/goops.h (SCM_SET_CLASS_INSTANCE_SIZE):
* libguile/goops.c (scm_sys_inherit_magic_x, scm_make_class): Remove
uses and definition of SCM_SET_CLASS_INSTANCE_SIZE. Light structs used
it, but you have that info in the layout; and foreign classes used it,
but that is going away soon anyway :)
Entities were meant to be a form of applicable struct. Unfortunately,
the implementation is intertwingled with generics. Removing them, for
now, will make it possible to cleanly re-add applicable struct support.
* libguile/struct.h (SCM_STRUCTF_ENTITY): Remove.
(SCM_STRUCTF_GOOPS_HACK): New flag; sigh.
* libguile/struct.c (scm_make_struct): We make "entity" structs if the
GOOPS_HACK flag is set. This will be fixed when we rework flags and
remove hidden words.
* libguile/goops.c (scm_class_of): Structs are not applicable, for now
at least.
(scm_sys_inherit_magic_x, scm_basic_basic_make_class)
(scm_sys_allocate_instance, scm_sys_set_object_setter_x):
(make_struct_class): Adapt for no more entities (and thus no entity
flag).
(create_standard_classes): For some reason, generic functions were
getting the LIGHT flag set, after the ENTITY flag was removed; so for
now explicitly clear that flag.
* libguile/goops.h (SCM_GENERIC_SETTER, SCM_SET_GENERIC_SETTER): New
macros.
* libguile/objects.h:
* libguile/objects.c: Remove code for entities.
* libguile/debug.c: (scm_procedure_source): Only work with generics.
* libguile/eval.c (scm_trampoline_0, scm_trampoline_1)
(scm_trampoline_2): Only handle generics.
* libguile/eval.i.c (CEVAL): #ifdef out the pieces about entities.
* libguile/procprop.c (scm_i_procedure_arity): Remove support for
entities.
* libguile/procs.c (scm_procedure_p, scm_procedure, scm_setter): Remove
entity support.
* libguile/goops.h (SCM_GENERIC_METHOD_CACHE)
(SCM_SET_GENERIC_METHOD_CACHE): Two new macros; the same as
SCM_[SET_]ENTITY_PROCEDURE, but more reflecting the reality of the
generic hack.
* libguile/eval.i.c:
* libguile/goops.c:
* libguile/objects.c:
* libguile/vm-i-system.c: Use the new macros when it is appropriate to
do so.
* libguile/goops.c (scm_make): In the pre-inst `make', default
`procedure' to #f, and read a `make-procedure' instead of
`compile-env'.
* libguile/goops.h (scm_si_make_procedure): This instead of
scm_si_compile_env.
* module/oop/goops.scm (make-method): Remove this unused function. Users
should use (make <method> ...) directly.
(method): Capture `make-procedure' instead of `procedure' in the case
that the body calls a next-method. Allows for the kind of
"recompilation" that we were using before, but with closures instead of
re-entering the compiler. Type-specific compilation is still
interesting, but probably should be implemented in another way.
(initialize): Default #:procedure to #f, and
s/compile-env/make-procedure/.
* module/oop/goops/compile.scm (code-table-lookup): Just return the
cmethod, not the entry -- since the entry is now just (append types
cmethod).
(compile-make-procedure): New procedure, returns a form that, when
evaluated/compiled, will yield a procedure of one argument, the
next-method. When called with a next-method, the procedure returns an
actual method implementation. compile-make-procedure returns #f if the
body doesn't call next-method.
(compile-method): Unify to always return procedures. Much cleaner and
*much* faster in the compiled case. In the interpreted case, there
might be a slight slowdown, but if there is one it should be slight.
* module/oop/goops/dispatch.scm (method-cache-install!): Adapt to removal
of compute-entry-with-cmethod.
* libguile/goops.c (scm_port_class): Statically allocate it.
(create_port_classes): Don't use `scm_calloc ()'.
* libguile/goops.h (scm_port_class): Update declaration.
* libguile/ports.c (scm_make_port_type): When checking whether
GOOPS is initialized, check whether the first element of
SCM_PORT_CLASS is non-zero.
* libguile/goops.c (scm_smob_class): Statically allocate it.
(create_smob_classes): Don't malloc(3) `scm_smob_class'.
* libguile/goops.h (scm_smob_class): Update declaration.
* libguile/smob.c (scm_make_smob_type, scm_set_smob_apply): When
checking whether GOOPS is initialized, check whether the first element
of SCM_SMOB_CLASS is non-zero.
* ice-9/boot-9.scm (compile-time-environment): Return #f instead of
erroring under the interpreter, a bit more sane.
* libguile/goops.c (create_standard_classes):
* libguile/goops.h (scm_si_formals, scm_si_body, scm_si_compile_env):
* oop/goops.scm (method, initialize): Add `formals', `body', and
`compile-env' slots to <method>.
scm_class_char, scm_class_pair, scm_class_procedure,
scm_class_string, scm_class_symbol,
scm_class_procedure_with_setter, scm_class_primitive_generic,
scm_class_vector, scm_class_null, scm_class_real,
scm_class_complex, scm_class_integer, scm_class_fraction,
scm_class_unknown, scm_port_class, scm_smob_class,
scm_no_applicable_method, scm_class_of): Moved from objects to
goops since they are only useable once goops has been loaded.
(scm_classes_initialized): Removed.
(scm_class_of): Do not check it.
(create_standard_classes): Do not set it.
SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h".
Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and
scm_is_bool, respectively.
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.
(<class> <operator-class> <entity-class> <entity>): Marked as
replacements.
(upgrade-accessor): Renamed from upgrade-generic-with-setter.
(ensure-accessor, upgrade-accessor): Rewritten to accomodate the
new <accessor> class.
(merge-accessors): Provide for merging of accessors imported from
different modules under the same name.
* goops.c, goops.h (scm_class_accessor_method): Renamed from
scm_class_accessor.
(scm_class_accessor): New class.
with the versions in this module using
scm_c_extend_primitive_generic.
* goops.scm (equal?): Define default method.
* goops.c (scm_primitive_generic_generic): Enable primitive
generic if not enabled.
(scm_sys_goops_loaded): Setup unextended primitive generics.
* goops.c, goops.h (scm_c_extend_primitive_generic): New function.
* snarf.h (SCM_PRIMITIVE_GENERIC, SCM_PRIMITIVE_GENERIC_1): New
snarf macros.
* numbers.c (scm_abs): Use SCM_PRIMITIVE_GENERIC. (This is only a
testing example. All uses of SCM_GPROC should be converted.)
* procprop.c (scm_stand_in_scm_proc): Use scm_assq instead of
scm_assoc.
* eq.c (scm_equal_p): Turned into a primitive generic.
compute-new-list-of-methods): Use methods slot directly instead of
generic-function-methods.
(upgrade-generic-with-setter): Handle <extended-generic>:s.
(define-extended-generic): New syntax.
(make-extended-generic): New function.
* goops.c, goops.h (scm_class_extended_generic_with_setter): New
class.
(scm_compute_applicable_methods): Use scm_generic_function_methods.
* goops.c (scm_generic_function_methods): Support extended
generic functions.
Added lots of comments regarding the implementation of #@dispatch.
Changed intra-procedure communication to use t.arg1 instead of
arg2. Removed some uses of t.arg1, t.lloc and proc as temporary
variables. Introduced temporary variables with hopefully
descriptive names for clarification. Replaced SCM_N?IMP by a more
explicit predicate in some places. Use SCM_INSTANCE_HASH instead
of computing the expression explicitly. Eliminate now unused
label nontoplevel_cdrxbegin.
* goops.h (SCM_INSTANCE_HASH): New macro.
* objects.h (SCM_CMETHOD_FORMALS, SCM_CMETHOD_BODY): New macros.
comments.
(scm_deval_args, deval_args): Renamed scm_deval_args to
deval_args, since it is not part of the interface.
(SCM_CEVAL): Added (maybe somewhat verbose) comment. Avoid to
use references to debug.vect[0] before it exists. Add parentheses
to switch statement.
* goops.h: Added local emacs variables.