summaryrefslogtreecommitdiff
path: root/module/rnrs/records
AgeCommit message (Collapse)AuthorFilesLines
2020-01-12Fix typos in previous commit.Andy Wingo1-1/+1
* module/ice-9/boot-9.scm (record-modifier): * module/rnrs/records/procedural.scm (make-record-type-descriptor): Fix typos.
2020-01-12Optionally allow duplicate field names in core recordsAndy Wingo1-1/+2
* NEWS: Update. * doc/ref/api-data.texi (Records): Update docs. * module/ice-9/boot-9.scm (make-record-type): Add #:allow-duplicate-field-names? keyword argument. (record-accessor, record-modifier): Allow passing indexes to identify fields. * module/rnrs/records/procedural.scm (make-record-type-descriptor): Allow duplicate field names. Fixes #38611.
2019-10-30Remove circularity in r6rs by rebasing conditions on core recordsAndy Wingo2-85/+32
* module/rnrs/conditions.scm: Use core record facilities to define the base condition types, define-condition-type, and the standard condition hierarchy. (simple-condition?): Rename from condition-internal?. * module/rnrs/exceptions.scm: Move `raise' definition here, out from the procedural records layer. (format-simple-condition): Reimplement in a simpler way, hopefully producing the same output. * module/rnrs/records/procedural.scm: * module/rnrs/records/inspection.scm: Import the exceptions and conditions modules, and use the normal raise function.
2019-10-29Rebase R6RS records on top of core recordsAndy Wingo2-237/+159
* module/ice-9/boot-9.scm (record-type-uid): New accessor. (make-record-type): Record UID in record type properties. * module/rnrs/conditions.scm (define-condition-type): Fix invalid invocation of make-record-type. * module/rnrs/records/inspection.scm: Rewrite to use core record inspection facilities. * module/rnrs/records/procedural.scm: Rewrite to use core make-record-type. Incidentally the result is that instances of derived R6RS record types are now flat instead of nested. * test-suite/tests/r6rs-records-procedural.test ("make-record-type-descriptor"): Relax a couple condition type checks, while we redo the exception system.
2017-09-23Replace "pr" struct fields with "pw" fieldsAndy Wingo1-4/+4
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Layout is a "pr" field. * module/ice-9/boot-9.scm (record-type-vtable): Record vtable fields are writable. (<parameter>): "pw" fields. * module/oop/goops.scm (<class>, %compute-layout): <read-only> fields are "pw" underneath. * module/rnrs/records/procedural.scm (record-type-vtable) (record-constructor-vtable, make-record-type-descriptor): Use "pw" fields in vtables. * module/srfi/srfi-35.scm (%condition-type-vtable) (struct-layout-for-condition): "pw" fields in vtables. * test-suite/tests/goops.test: * test-suite/tests/structs.test: Use "pw" fields only. * benchmark-suite/benchmarks/structs.bm: Update for make-struct/no-tail, to use pw fields, and also to remove useless tests that the compiler would optimize away. * doc/ref/api-data.texi (Vtables): Add a note about the now-vestigial permissions character and update documentation. (Structure Basics, Meta-Vtables): Update examples. * libguile/hash.c (scm_i_struct_hash): Remove code that would handle opaque/self fields. * libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use "pw" fields. * libguile/struct.c (scm_struct_init): Simplify check for hidden fields. * libguile/values.c (scm_init_values): Field is "pw".
2017-09-22Merge stable-2.2 into masterAndy Wingo1-18/+19
This commit resolves conflicts by removing the deprecated make-struct.
2017-09-20Use make-struct/no-tail instead of make-structAndy Wingo1-18/+19
* module/ice-9/boot-9.scm: * module/language/cps/effects-analysis.scm: * module/language/elisp/falias.scm: * module/language/tree-il.scm: * module/language/tree-il/primitives.scm: * module/rnrs/records/procedural.scm: * module/srfi/srfi-35.scm: * module/system/base/syntax.scm: Change uses of make-struct to make-struct/no-tail.
2017-09-14remove self field of vtablesAndy Wingo1-10/+12
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT, scm_vtable_index_self): Remove "self" field. Renumber the other fields. * module/oop/goops.scm (<self-slot>): Remove. (fold-class-slots): Adapt for "self" slot removal. Adapt all users. (class-redefinition): Now that there is no "self" slot to update, use %modify-instance instead of %modify-class. * libguile/goops.c (class_self): Remove. (scm_sys_modify_class): Remove. * libguile/goops.h (scm_sys_modify_class): Remove. * module/rnrs/records/procedural.scm: Import vtable-offset-user. Renumber rtd indexes using vtable-offset-user. * module/srfi/srfi-35.scm (%condition-type-vtable): Remove mention of vtable fields. * module/system/base/types.scm (address->inferior-struct): Adapt for different vtable field layout.
2011-11-01Fix R6RS `fold-left' so the accumulator is the first argument.Ian Price1-2/+2
* module/rnrs/lists.scm (fold-left): New procedure. * module/rnrs/records/syntactic.scm (define-record-type): Fix to use corrected `fold-left'. * test-suite/tests/r6rs-lists.test: Add tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2011-06-19Fix hygiene issues with `define-record-type'Ian Price1-153/+143
* module/rnrs/records/syntactic.scm (define-record-type0, process-fields): Preserve hygiene of record clauses. * test-suite/tests/r6rs-records-syntactic.test ("record hygiene"): Add tests.
2010-11-25Some tweaks to the R6RS supportAndreas Rottmann2-18/+22
* module/rnrs/base.scm (error, assert): Define -- they were missing. (assertion-violation): Properly treat a #f `who' argument. * module/rnrs/conditions.scm (condition): Use `assertion-violation' instead of the undefined `raise'. (define-condition-type): Fix for multiple fields. * test-suite/tests/r6rs-conditions.test: Test accessors of a multiple-field condition. Also import `(rnrs base)' to allow stand-alone running of the tests; apparently the `@' references scattered throughout the R6RS modules make the libraries sensitive to their load order -- for instance, trying to load `(rnrs conditions)' before `(rnrs base)' is loaded fails. * module/rnrs/records/inspection.scm: Use `assertion-violation' instead of an explicit `raise'. * module/rnrs/records/syntactic.scm (process-fields): Use `syntax-violation' instead of bogus invocations of `error'.
2010-10-22Improve performance of R6RS records implementationJulian Graham2-72/+81
Reimplement record-type descriptors as vtables for record structs, saving us what was an expensive inspection of a record's vtable layout string to determine its type. * module/rnrs/records/inspection.scm (record-field-mutable?): Check mutability using the bit field stored in the record-type descriptor instead of the record struct's vtable. * module/rnrs/records/procedural.scm (record-internal?): Reimplement as a delegation to a check of the passed struct's vtable against `record-type-descriptor?'. (record-type-vtable): Modify to include base vtable layout as a prefix of the record-type-descriptor layout so that all record-type instances are now also vtables. (make-record-type-descriptor): Remove field vtable; build up a mutability bit field to use for fast mutability checks. (record-accessor, record-mutator): Use field struct and mutability bit field.
2010-08-28Several fixes to R6RS librariesAndreas Rottmann1-4/+7
* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Make this return an an exact integer instead of an inexact number. * module/rnrs/base.scm (assertion-violation): Implement. * module/rnrs/conditions.scm (simple-conditions): Allow also simple conditions as argument. * module/rnrs/enums.scm (define-enumeration): Properly construct empty enumeration sets. * module/rnrs/exceptions.scm (guard): Don't restrict the body to a single expression. * module/rnrs/records/syntactic.scm (define-record-type0): Expand into a series of definitions only.
2010-06-16remove encoding of versions into the file system (for now?)Andy Wingo3-0/+0
* module/ice-9/boot-9.scm (find-versioned-module): Remove. Still had some bugs (e.g. for "." in the path and in finding compiled files), did too much computation and statting, and we don't really want to promote versioning. Nor do we want to hard-code a particular encoding of versions in the file-system. Perhaps the real way to do this is to be extensible somehow. (try-module-autoload): Just dispatch to primitive-load-path in all cases. * module/rnrs * module/rnrs.scm: * module/rnrs/arithmetic/bitwise.scm: * module/rnrs/arithmetic/fixnums.scm: * module/rnrs/arithmetic/flonums.scm: * module/rnrs/base.scm: * module/rnrs/conditions.scm: * module/rnrs/control.scm: * module/rnrs/enums.scm: * module/rnrs/eval.scm: * module/rnrs/exceptions.scm: * module/rnrs/files.scm: * module/rnrs/hashtables.scm: * module/rnrs/io/simple.scm: * module/rnrs/lists.scm: * module/rnrs/mutable-pairs.scm: * module/rnrs/mutable-strings.scm: * module/rnrs/programs.scm: * module/rnrs/r5rs.scm: * module/rnrs/records/inspection.scm: * module/rnrs/records/procedural.scm: * module/rnrs/records/syntactic.scm: * module/rnrs/sorting.scm: * module/rnrs/syntax-case.scm: * module/rnrs/unicode.scm: Move these files, eliding the "6/" infix, so that they are in the normal (unversioned) module path.
2010-05-20Explicitly import `@@' to support R6RS library purification enhancementsJulian Graham1-1/+1
on `master'. * module/rnrs/6/conditions.scm: * module/rnrs/6/exceptions.scm: * module/rnrs/6/files.scm: * module/rnrs/6/hashtables.scm: * module/rnrs/io/6/simple.scm: * module/rnrs/records/6/inspection.scm: Add explicit import for `@@'.
2010-05-20Test suite and fixes for R6RS (rnrs conditions) andJulian Graham1-3/+0
(rnrs records procedural). * module/rnrs/6/conditions.scm: Fix export of make-implementation-restriction-violation; remove dependency on (rnrs syntax-case); remove redundant function compound-condition-components; rewrite define-condition-type using syntax-rules instead of syntax-case. * module/rnrs/records/6/procedural.scm: Remove serious-condition?, violation? and assertion-violation? predicates, since they're not true condition predicates. * test-suite/Makefile.am: Add tests/r6rs-conditions.test to SCM_TESTS. * test-suite/tests/r6rs-conditions.test: New file.
2010-05-20Add `guard' form and test cases to R6RS (rnrs exceptions) library.Julian Graham1-1/+1
* module/rnrs/6/exceptions.scm: (guard0, guard): New syntax. * module/rnrs/records/6/procedural.scm: (r6rs-raise-continuable): Can't use `raise' here because it's exported by (rnrs exceptions); use plain old `throw' instead. * test-suite/Makefile.am: Add tests/r6rs-exceptions.test to SCM_TESTS. * test-suite/tests/r6rs-exceptions.test: New file.
2010-05-20Implementation for the R6RS (rnrs hashtables) library;Julian Graham2-92/+145
Implementation and test cases for the R6RS (rnrs record syntactic) library. * module/Makefile.am: Add rnrs/6/hashtables.scm to RNRS_SOURCES. * module/rnrs/6/hashtables.scm: New file. * module/rnrs/records/6/inspection.scm: (record-type-generative?) Record types are generative iff they have no uid, not vice-versa. * module/rnrs/records/6/syntactic.scm: Finish `define-record-type' implementation; add `record-type-descriptor' and `record-constructor-descriptor' forms. * test-suite/Makefile.am: Add tests/r6rs-records-syntactic.test to SCM_TESTS. * test-suite/tests/r6rs-records-inspection.test: Update tests for `record-type-generative?' to reflect corrected behavior. * test-suite/tests/r6rs-records-syntactic.test: New file.
2010-05-20Implementation and test cases for the R6RS (rnrs records inspection)Julian Graham2-52/+157
library. * module/Makefile.am: Add module/rnrs/records/6/inspection.scm to RNRS_SOURCES. * module/rnrs/records/6/inspection.scm: New file. * module/rnrs/records/6/procedural.scm: Assorted refactoring: Create index constants for record, rtd, and rcd field indexes; record-type-vtable, record-constructor-vtable: More informative display names; (make-record-type-descriptor): fold left, not right when creating vtable; store field names as vector, not list; detect opaque parents * test-suite/Makefile.am: Add test-suite/tests/r6rs-records-inspection.test to SCM_TESTS. * test-suite/tests/r6rs-records-inspection.test: New file.
2010-05-20Implementation and test cases for the R6RS (rnrs records procedural) library,Julian Graham2-0/+456
along with its dependencies. * module/Makefile.am: Add new R6RS libraries below to RNRS_SOURCES. * module/rnrs/6/conditions.scm, exceptions.scm, syntax-case.scm: New files. * module/rnrs/io/6/simple.scm: New file. * module/rnrs/records/6/procedural.scm, syntactic.scm: New files. * test-suite/Makefile.am: Add tests/r6rs-records-procedural.test to SCM_TESTS. * test-suite/tests/r6rs-records-procedural.test: New file.