summaryrefslogtreecommitdiff
path: root/module/oop/goops
AgeCommit message (Collapse)AuthorFilesLines
2020-09-10Move copy-tree to (ice-9 copy-tree); deprecate main bindingAndy Wingo1-6/+7
* doc/ref/api-data.texi (List Constructors): * doc/ref/api-utility.texi (Copying): Update docs to mention module. * libguile.h: Remove trees.h inclusion. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Remove trees.c, trees.h, and related files. * libguile/init.c (scm_i_init_guile): Remove trees.h and the scm_init_trees call. * libguile/trees.c: * libguile/trees.h: Remove. * module/Makefile.am (SOURCES): Add ice-9/copy-tree.scm. * module/ice-9/copy-tree.scm: New file. * module/ice-9/deprecated.scm (copy-tree*): Export as copy-tree, proxying to (ice-9 copy-tree). * module/system/repl/common.scm: * module/web/client.scm: * test-suite/tests/elisp.test: * test-suite/tests/srfi-1.test: * module/oop/goops/save.scm: Use (ice-9 copy-tree). * test-suite/Makefile.am (SCM_TESTS): Add copy-tree.test. * test-suite/tests/copy-tree.test: New file; test pulled from eval.test. * libguile/deprecated.h: * libguile/deprecated.c (scm_copy_tree): Deprecate.
2015-01-23Update (oop goops save) for <slot> objectsAndy Wingo2-34/+26
* 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.
2015-01-23Introduce <slot> objects in GOOPSAndy Wingo2-3/+5
* 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".
2015-01-23The GOOPS "unbound" value is a unique pairAndy Wingo2-4/+6
* 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.
2015-01-23Fold (oop goops util) into (oop goops)Andy Wingo2-44/+1
* 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.
2015-01-23GOOPS utils module cleanupsAndy Wingo1-18/+1
* 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.
2015-01-23append-map rather than mapappendAndy Wingo1-4/+2
* module/oop/goops/util.scm: Remove mapappend alias; SRFI-1 append-map should be used instead.
2015-01-23Fold GOOPS compile and dispatch modules into main GOOPS moduleAndy Wingo2-332/+0
* 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.
2015-01-23Remove unused %fast-slot-ref / %fast-slot-set! from GOOPSAndy Wingo1-5/+5
* 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).
2014-02-07Merge commit 'f6ddf827f8f192af7a8cd255bd8374a0d38bbb74'Andy Wingo2-2/+2
Conflicts: module/ice-9/boot-9.scm module/oop/goops.scm
2014-01-23Improve correctness and consistency of 'eval-when' usage.Mark H Weaver2-2/+2
* 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.
2013-01-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo4-46/+48
Conflicts: module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/bytecode/spec.scm module/language/tree-il/spec.scm
2013-01-26Clarify the copyright status of GOOPS.Ludovic Courtès3-28/+25
* 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>.
2013-01-23oop goops save: fix compile-time availability of write-componentAndy Wingo1-18/+23
* 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.
2013-01-23merge stable-2.0Andy Wingo1-2/+4
There are some bugs with command-line handling that will be sorted out with the next commit.
2013-01-20Fix attempt to get handle of weak table in (oop goops save)Andy Wingo1-2/+4
* module/oop/goops/save.scm (readable?): Fix. Thanks to Andrew Gaylard for the report.
2012-07-06Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-0/+1
Conflicts: libguile/expand.c libguile/hashtab.c libguile/ports.c libguile/vectors.c libguile/weaks.c module/language/ecmascript/compile-tree-il.scm module/language/tree-il/effects.scm module/language/tree-il/fix-letrec.scm module/language/tree-il/peval.scm test-suite/tests/peval.test
2012-07-05fix goops compilation when current language is not schemeAndy Wingo1-0/+1
* module/oop/goops/dispatch.scm (compute-dispatch-procedure): Set source language to Scheme, not (current-language).
2012-06-22Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-5/+10
Conflicts: libguile/deprecated.c libguile/ports.c libguile/ports.h libguile/strports.c test-suite/tests/cse.test
2012-06-20Fix cross-compilation of GOOPS-using code.Ludovic Courtès1-5/+10
Fixes <http://bugs.gnu.org/11645>. Reported by Bogdan A. Marinescu <bogdan.a.marinescu@intel.com>. * module/oop/goops/dispatch.scm (compute-dispatch-procedure)[comp]: Wrap `compile' call in (with-target %host-type ...).
2012-05-23Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-12/+2
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
2012-05-23finish deprecating eval closuresAndy Wingo1-9/+12
* libguile/deprecated.h: * libguile/deprecated.c (scm_eval_closure_lookup) (scm_standard_eval_closure, scm_standard_interface_eval_closure) (scm_eval_closure_module): Deprecate these, as they are unused. * libguile/modules.h: * libguile/modules.c: Remove deprecated code. * module/oop/goops/util.scm (top-level-env, top-level-env?): Deprecate. * module/ice-9/deprecated.scm (set-system-module!): Deprecate. (module-eval-closure): Deprecate, by overriding the core definition to return a fresh eval closure. * module/ice-9/boot-9.scm (make-module): Don't set an eval closure on the module. (the-root-module, the-scm-module): Don't call set-system-module!.
2012-04-23disable optimizations in goops dispatch proceduresAndy Wingo1-2/+4
* module/oop/goops/dispatch.scm: Disable peval and cse.
2011-09-02more define-syntax-rule usageAndy Wingo2-10/+6
* module/ice-9/boot-9.scm: * module/ice-9/control.scm: * module/ice-9/futures.scm: * module/ice-9/optargs.scm: * module/ice-9/poll.scm: * module/ice-9/receive.scm: * module/ice-9/threads.scm: * module/ice-9/vlist.scm: * module/language/assembly/compile-bytecode.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/tree-il.scm: * module/oop/goops.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: * module/srfi/srfi-1.scm: * module/srfi/srfi-35.scm: * module/srfi/srfi-39.scm: * module/srfi/srfi-45.scm: * module/srfi/srfi-67/compare.scm: * module/sxml/match.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/vm/inspect.scm: * module/texinfo.scm: * module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-01-30Fix GOOPS method compilation bug when no next-method existsMark H Weaver1-1/+1
* 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.
2010-04-24fix some uses of %module-public-interfaceAndy Wingo3-7/+10
* module/ice-9/r5rs.scm: * module/ice-9/safe-r5rs.scm: * module/oop/goops/save.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: Fix some uses of %module-public-interface.
2010-04-22(app modules) -> (%app modules)Andy Wingo1-2/+2
* 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).
2009-12-04eval.c closures are now applicable smobs, not tc3sAndy Wingo1-5/+2
* 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?.
2009-11-26push goops compile delay out to 30 invocations, for great justiceAndy Wingo1-1/+1
* module/oop/goops/dispatch.scm (timer-init): Init to 30 for faster goops load time.
2009-11-26remove code that manages the method cacheAndy Wingo1-2/+2
* 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.
2009-11-26remove method cache management code from (oop goops dispatch)Andy Wingo1-219/+7
* module/oop/goops/dispatch.scm: Remove old method cache things.
2009-11-26generics now dispatch as applicable structsAndy Wingo1-22/+27
* 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.
2009-11-26limn goops flags, remove foreign objs, rename entity to applicable-structAndy Wingo1-2/+2
* 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.
2009-11-26generic dispatch protocol in scheme, not yet wired upAndy Wingo1-1/+220
* 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.
2009-11-26more clarity in (oop goops dispatch)Andy Wingo1-10/+1
* 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.
2009-11-26remove code-table slot from methodsAndy Wingo1-28/+2
* 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.
2009-11-26remove used-by slot from genericsAndy Wingo1-2/+0
* 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.
2009-11-26a very big commit cleaning up structs & goops. also applicable structs.Andy Wingo1-1/+1
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.
2009-11-16SCM_DEBUG fix: Don't apply SCM_CAR to non-pairs when walking argumentKen Raeburn1-2/+2
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.
2009-11-07Fix typos leading to wrong argument counts.Ludovic Courtès1-1/+1
* 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'.
2009-09-21Remove unused variables in ice-9/goops/srfi/scripts.Ludovic Courtès3-9/+5
* module/ice-9/boot-9.scm (scm-style-repl)[-abort]: Remove. * module/oop/goops.scm (class)[slot-defs]: Remove. (compute-slot-accessors)[name]: Remove. (compute-get-n-set)[env]: Remove. * module/oop/goops/active-slot.scm (compute-get-n-set)[env, name]: Remove. * module/oop/goops/dispatch.scm (cache-try-hash!)[max-misses]: Remove. * module/oop/goops/save.scm (make-mapper)[dims]: Remove. * module/scripts/autofrisk.scm (>>checks)[prog]: Remove. * module/srfi/srfi-19.scm (priv:read-directives)[ireaderf, eireader4]: Remove.
2009-06-17Change Guile license to LGPLv3+Neil Jerram11-21/+20
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-06-07fix bug in goops' method cache with rest argsAndy Wingo1-5/+6
* module/oop/goops/compile.scm (code-table-lookup): Fix a tricky little bug! * test-suite/tests/goops.test ("the method cache"): Add a wee test.
2009-05-21rewrite `method' as a hygienic macro to re-allow lexical specializersAndy Wingo1-30/+2
* 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.
2009-04-25all of guile compiles now, expanded with syncaseAndy Wingo3-50/+30
* 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.
2009-04-25fix bad syntax in define-macro, (ice-9 match), and (oop goops)Andy Wingo1-3/+2
* 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.
2009-04-24merge ice-9, srfi, oop makfiles into module makefileAndy Wingo1-30/+0
* 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.
2009-03-20speed up goops rehashingAndy Wingo1-19/+15
* module/oop/goops/dispatch.scm (cache-try-hash!): Speed up goops rehashing, in theory. I haven't measured, though.
2009-03-06Replace eval-case with eval-whenAndy Wingo2-2/+2
* 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.
2009-02-13don't re-enter the compiler during method dispatchAndy Wingo2-156/+41
* 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.