* module/oop/goops.scm, module/oop/goops/active-slot.scm,
module/oop/goops/composite-slot.scm, module/oop/goops/describe.scm:
Add a copyright line for Érick Gallesio. Mention the STk version
GOOPS was derived from. Remove mentions of the ‘COPYRIGHTS’ file.
Thanks to Karl Berry <karl@freefriends.org> for pointing it out, and
to Michael Djurfeldt <mikael@djurfeldt.com>.
* module/oop/goops/save.scm (write-component)
(write-component-procedure): Move definitions up so that syntax
definition is available when compiling the rest of the file.
This commit removes code that was newly deprecated in stable-2.0.
Conflicts:
libguile/deprecated.c
libguile/deprecated.h
libguile/modules.c
module/ice-9/boot-9.scm
module/ice-9/deprecated.scm
This was a pretty big merge involving a fair amount of porting,
especially to peval and its tests. I did not update psyntax-pp.scm,
that comes in the next commit.
Conflicts:
module/ice-9/boot-9.scm
module/ice-9/psyntax-pp.scm
module/language/ecmascript/compile-tree-il.scm
module/language/tree-il.scm
module/language/tree-il/analyze.scm
module/language/tree-il/inline.scm
test-suite/tests/tree-il.test
* module/oop/goops.scm (extended-by!, not-extended-by!)
(upgrade-accessor, merge-generics): Invalidate the method cache after
munging "extends" or "methods" fields.
(invalidate-method-cache!): A new wrapper around
%invalidate-method-cache!, that will also invalidate the caches of
"extended-by" generics.
(internal-add-method!, remove-class-accessors!): Use the new
invalidate-method-cache!.
* libguile/goops.c (DEFVAR): Remove this helper macro, replacing its
uses with scm_module_define, but without scm_module_export.
(create_basic_classes, scm_init_goops_builtins): Update callers.
(make_class_from_template, make_class_from_symbol): Change to not
define variables for classes. This affects ports, struct classes, and
smob classes.
* module/oop/goops.scm: Explicitly list our exports, so there is no more
trickery happening in C.
(find-subclass): Private helper to grub the class hierarchy, so we can
define bindings for smobs, ports, etc. Use to define the classes that
goops.c used to define -- probably a subset, but it's better to have
them listed.
* module/oop/goops.scm (ensure-generic): If the old definition of a
desired getter is a primitive generic, let the new method be added to
it instead of creating a fresh new generic.
(ensure-accessor): Modify as necessary to keep the old behavior.
Maybe something more optimal can be done here, but it's not yet
obvious to me how to do it.
* module/oop/goops/compile.scm (compute-cmethod): Fix a bug
that caused the method compiler to barf while compiling a
method that calls (next-method), if there is no applicable
next method.
* module/ice-9/debugging/breakpoints.scm (module-if-already-loaded):
(all-loaded-modules):
* module/oop/goops/stklos.scm: Fix instances of (app modules) to be
(%app modules).
* 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/tags.h: Remove tc7 #defines for subrs, replacing them with
placeholders. These were public, but hopfully unused. I don't see how
to usefully deprecate them.
* libguile/array-map.c (scm_array_map_x): Remove special cases for
certain subr types. This might make things slower for the moment,
otoh, native compilation should moot that question.
* libguile/eval.i.c:
* libguile/eval.c: Remove subr-handling cases. To regain this speed and
more won't have to wait for native compilation, though -- this change
smooths the way for subr dispatch in the VM.
* libguile/gsubr.c (scm_i_gsubr_apply): Fix a bug in which we didn't
detect too-many-arguments. This would only show up when using ceval,
as only ceval called this function.
* test-suite/tests/ramap.test ("array-map!"): Change the expected
exception if passed a procedure of the wrong arity. It now gives
wrong-num-args.
more won't have to wait for native compilation, though -- this change
smooths the way for subr dispatch in the VM.
* libguile/goops.c (scm_class_of): Remove subr cases. No speed
implication.
* libguile/objects.c (scm_valid_object_procedure_p): Remove this public
but undocumented, and useless, function. I do not think this will
affect anyone at all.
(scm_set_object_procedure_x): Replace a call to
scm_valid_object_procedure_p with scm_procedure_p, and actually wrap
with a scm_is_true.
* module/oop/goops.scm (initialize-object-procedure): Don't call
valid-object-procedure?.
* module/oop/goops.scm (@slot-ref, @slot-set!): Define "primitives" for
these. Probably should do something more general, though, allowing
@struct-ref.
* module/language/tree-il/primitives.scm (add-interesting-primitive!):
Error if the primitive isn't bound.
* module/ice-9/debugger/commands.scm:
* module/ice-9/debugging/traps.scm:
* module/ice-9/emacs.scm:
* module/ice-9/gds-client.scm: Add some FIXMEs due to impending
local-eval removal.
* module/oop/goops.scm (make-generic-bound-check-getter): Just the
compiled closure case here.
* 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.
* module/oop/goops/dispatch.scm: Add a dispatch protocol in Scheme. The
idea is that instead of using a hardcoded C protocol, we compile
dispatch procedures at runtime. To avoid too much thrashing at bootup,
there is a simple JIT mechanism -- dispatch will be data-driven,
through the cache, for the first 5 invocations, then a dispatch
procedure will be compiled from the cache.
My initial timings indicate that interpreted dispatch takes about
100us, and that compiled dispatch takes about 60us. Compilation itself
takes about 16000us (16 ms). The compiled procedure dispatch times
will improve soon, hopefully.
* libguile/eq.c (scm_eqv_p): Not a generic any more. Since eqv? is used
by e.g. `case', which should be able to compile into dispatch tables,
it really doesn't make sense to dispatch out to a generic.
(scm_equal_p): So it was always the case that (equal? 'foo "foo") =>
#f. But (equal? 'foo 'bar) could actually be extended by a generic.
This was a bug, if you follow the other logic of the code. Changed so
that generic functions can only extend the domain of equal? when
operating on goops objects.
* oop/goops.scm: No more eqv? generic.
* test-suite/tests/goops.test: Remove eqv? tests.
* module/oop/goops/dispatch.scm (memoize-method!): If we don't have a
no-applicable-method, just call no-applicable-method directly.
* test-suite/tests/goops.test ("no-applicable-method"): Add some tests.
* 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.
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.
lists in method cache matching.
* libguile/goops.c (scm_mcache_lookup_cmethod): Don't apply SCM_CAR to
non-pairs when walking argument lists in method cache matching.
Don't check for CLASSP or symbol in the car slot, since the end of
the specifier list is a non-pair. Update comments to reflect new
structure of method cache entry.
* module/oops/goops/dispatch.scm: Update comments here too.