This module replaces the method and define-method bindings with their
method* and define-method* counterparts, for use by users who prefer not
to use both kinds of syntactic forms.
* module/oop/goops/keyword-formals.scm: New module.
* am/bootstrap.am: Added
* doc/ref/goops.texi: Document this change.
* module/oop/goops/describe.scm (describe): Remove commented code.
* module/oop/goops/save.scm (get-set-for-each, access-for-each): Update
these hoary routines for the new <slot> universe.
* module/oop/goops.scm (fold-class-slots): Change format to use proper
slot specifications.
(fold-slot-slots): Flesh out with all needed slots.
(<class>): Update cons-layout to deal with new fold-class-slots form.
Don't create slots; we do that later.
(is-a?, get-keyword, *unbound, unbound?, %allocate-instance): Move
definitions up.
(<slot>, slot?): New definitions.
(slot-definition-name, slot-definition-allocation)
(slot-definition-init-keyword, slot-definition-init-form)
(slot-definition-init-value, slot-definition-init-thunk)
(slot-definition-options, slot-definition-getter)
(slot-definition-setter, slot-definition-accessor)
(slot-definition-slot-ref, slot-definition-slot-set!)
(slot-definition-index, slot-definition-size): New definitions as
accessors on <slot> objects.
(class-slot-definition): Adapt to class-slots change.
(direct-slot-definition-class, make-slot): New definitions.
(make): Define a boot version that can allocate <slot> instances.
(compute-direct-slot-definition)
(compute-direct-slot-definition-initargs)
(effective-slot-definition-class, compute-effective-slot-definition):
New definitions.
(build-slots-list): Adapt to slots being <slot> objects.
(compute-get-n-set): New boot definition.
(allocate-slots): New definition. Replaces
compute-getters-n-setters.
(%compute-layout, %prep-layout): Adapt to changes.
(make-standard-class): Make <slot> objects for direct-slots, and
handle the allocate-slots protocol.
(<foreign-slot>): Inherit from <slot>.
(get-slot-value-using-name, set-slot-value-using-name!)
(test-slot-existence): Adapt to using slot definition objects.
(make-class): Allow slot specs or <slot> objects as the `slots'
argument.
(write): New method on <slot>.
(class-slot-ref, class-slot-set!): Reimplement.
(compute-slot-accessors, compute-getter-method)
(compute-setter-method): Adapt to changes.
(compute-getters-n-setters): Remove. Yay!
(compute-get-n-set): Adapt to use effective slot definitions instead
of the getters-n-setters for #:class / #:each-subclass allocation.
(%initialize-object): Adapt.
(initialize): New method for <slot>. Adapt method for <class>.
* module/oop/goops/active-slot.scm (compute-get-n-set):
* module/oop/goops/composite-slot.scm (compute-propagated-get-n-set):
Use slot-definition-options to access options of slot.
* test-suite/tests/goops.test ("bad init-thunk"): Fix to be a "pass-if"
instead of an "expect-fail".
* libguile/goops.c (SCM_GOOPS_UNBOUND, SCM_GOOPS_UNBOUNDP): Remove
internal macros.
(scm_make_unbound, scm_unbound_p): Remove internal functions.
(scm_sys_clear_fields_x): Add "unbound" parameter, for the init
value.
* module/oop/goops.scm (*unbound*): Define in Scheme as a simple
heap-allocated value.
(unbound?): New definition.
(%allocate-instance): Pass *unbound* to %clear-fields!.
(make-class, slot-definition-init-value)
(slot-definition-init-form, make-closure-variable): Use *unbound*
instead of (make-unbound), which is now gone.
* module/oop/goops/active-slot.scm (compute-get-n-set): Use *unbound*
instead of make-unbound. This module uses the GOOPS internals module;
perhaps we should export make-unbound or something...
* module/oop/goops/save.scm (make-unbound): Export our own make-unbound
definition, for use by residualized save code.
* module/language/ecmascript/base.scm (<undefined>, *undefined*): Use a
unique object kind and instance for the undefined value.
* libguile/vm.c (scm_i_vm_mark_stack): Fill the stack with
SCM_UNSPECIFIED instead of SCM_UNBOUND.
* module/oop/goops/util.scm: Removed. Instead we fold these definitions
into goops.scm.
* module/oop/goops/save.scm: Remove useless import of util.scm.
* module/oop/goops.scm: Fold in util.scm. Since we always use
add-interesting-primitive!, import (language tree-il primitives) in
the header. Clean up some early comments, and use of eval-when.
* module/Makefile.am: Adapt.
* module/oop/goops.scm (make-class): Inline find-duplicate to its use
site.
* module/oop/goops/util.scm (improper->proper): Remove unused function.
(any, every): Don't re-export these from SRFI-1; users can get them
from SRFI-1 directly.
* libguile/goops.c (scm_sys_invalidate_method_cache_x): Remove C
interface to this internal method. Instead, internal callers are all
from Scheme, so we move the implementation to Scheme.
(scm_make): Dispatch to `make' in Scheme. This is an incompatible but
great change, as it fulfills the common user perception that scm_make
is the same as GOOPS's `make'.
(scm_sys_goops_early_init): Capture `make'.
(scm_no_applicable_method): Define in Scheme and capture in C.
* module/Makefile.am: Remove oop/goops/compile.scm and
oop/goops/dispatch.scm.
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm: Fold into goops.scm.
* module/oop/goops.scm: Fold in the generic compile and dispatch
modules. This eliminates a circularity that caused some eval-when
shenanigans, so remove the eval-whens as well. Reimplement the boot
version of `make' in Scheme, and make the <generic> `initialize'
method handle invalidation instead of the generic %allocate-instance.
(no-applicable-method): Define here. Import the utils module in the
normal define-module block.
* libguile/goops.h:
* libguile/goops.c (scm_sys_fast_slot_ref, scm_sys_fast_slot_set_x):
Remove these unused, unsafe functions. They were publically available
only to C.
* module/oop/goops/active-slot.scm (compute-get-n-set): Update to use
struct-ref / struct-set! instead of %fast-slot-ref / %fast-slot-set!
from (oop goops internal).
* module/ice-9/boot-9.scm:
* module/ice-9/i18n.scm:
* module/ice-9/poll.scm:
* module/ice-9/popen.scm:
* module/ice-9/r6rs-libraries.scm:
* module/oop/goops.scm:
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm:
* module/srfi/srfi-88.scm:
* module/system/foreign.scm:
* module/texinfo/serialize.scm: Change most uses of 'compile' to
'expand', except where we must avoid it during initial bootstrap
before the module system is loaded. Remove redundant uses of
'compile' where 'expand' is also given. Standardize on the
"(expand load eval)" order of conditions.
* 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
* 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/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.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.
* 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.
* module/ice-9/channel.scm (eval): Fix number of arguments to
`guile:eval'.
* module/oop/goops/save.scm (write-readably): Fix number of arguments to
`write-array'.
* module/srfi/srfi-19.scm (priv:char->int): Fix number of arguments to
`priv:time-error'.
* module/oop/goops.scm (method): Reimplement as a hygienic macro. This
seriously took me like 6 hours to figure out. Allows for lexical
specializers: (let ((<x> ...)) (define-method (foo (arg <x>)) ...)).
* module/oop/goops/compile.scm (next-method?, compile-make-procedure):
Remove these, as `method' does it all now, hygienically.
* libguile/eval.c (scm_m_eval_when): Whoops, eval-when has an implicit
begin. Fix.
* module/oop/goops.scm: Syncase doesn't like definitions in expression
context, and grudgingly I have decided to go along with that. But that
doesn't mean we can't keep the old semantics, via accessing the module
system directly. So do so. I took the opportunity to rewrite some
macros with syntax-rules and syntax-case -- the former is nicer than
the latter, of course.
* module/oop/goops/save.scm: Don't define within an expression.
* module/oop/goops/simple.scm (define-class): Use define-syntax.
* module/oop/goops/stklos.scm (define-class): Use define-syntax.
* module/ice-9/boot-9.scm (define-macro): Use syntax-case to destructure
macro arguments, so we get good errors.
* module/ice-9/match.scm (defstruct, define-const-structure): Don't
unquote in the `defstruct' macro as a value in expansions.
* module/oop/goops.scm (standard-define-class): Can't define a macro with
`define', use `define-syntax' instead.
(define-accessor): Use syntax-rules. Doesn't give us much in this case.
(toplevel-define!): New helper, to let us keep GOOPS' behavior with the
new expander. Some solution that works lexically and at the toplevel
would be nice, though.
(define-method): Reimplement with syntax-rules -- soooo much nicer.
* module/oop/goops/dispatch.scm (lookup-create-cmethod): Don't define
within an expression.
* configure.in: No longer output the Makefile.ins.
* module/Makefile.am: Include the contents of ice-9/, srfi/, and oop/.
* module/ice-9/Makefile.am:
* module/ice-9/debugger/Makefile.am:
* module/ice-9/debugging/Makefile.am:
* module/oop/Makefile.am:
* module/oop/goops/Makefile.am:
* module/srfi/Makefile.am: Removed.
* module/ice-9/boot-9.scm (eval-when): Replace eval-case with eval-when.
Eval-when is *much* simpler, and more expressive to boot. Perhaps in
the future we'll get 'visit and 'revisit too.
* module/ice-9/deprecated.scm (eval-case): Provide mostly-working
deprecated version of eval-case.
* module/ice-9/boot-9.scm (defmacro, define-macro): Relax condition: we
can make defmacros that are not at the toplevel now. But in the future
we should replace this implementation of defmacros with one written in
syntax-case.
(define-module, use-modules, use-syntax): Allow at non-toplevel.
(define-public, defmacro-public, export, re-export): Don't evaluate at
compile-time, I can't see how that helps things. Allow `export' and
`re-export' at non-toplevel.
* module/ice-9/getopt-long.scm:
* module/ice-9/i18n.scm:
* module/oop/goops.scm:
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm: Switch to use eval-when, not
eval-case.
* module/language/scheme/compile-ghil.scm (eval-when): Replace eval-case
transformer with eval-when transformer. Sooooo much simpler, and it
will get better once we separate expansion from compilation.
* module/language/scheme/expand.scm (quasiquote): Hm, expand quasiquote
properly. Not hygienic. Syncase needed.
(lambda): Handle internal defines with docstrings propertly.