* test-suite/tests/srfi-9.test ("incompatible field paths"): Rename
':bar' to 'bar' to avoid the possibility of the symbol name being
printed with #{...}# notation.
* module/system/base/ck.scm: New module.
* module/srfi/srfi-9.scm: Import (system base ck).
(getter-type, getter-index, getter-copier): Convert incoming argument
convention to CK form.
(define-tagged-inlinable): Convert return value convention for key
lookup to CK form.
* module/srfi/srfi-9/gnu.scm: Import (system base ck).
Rename '%set-fields-unknown-getter' to 'unknown-getter'.
(c-list, c-same-type-check): New macros.
(%set-fields): Using the CK abstract machine, arrange to check (at
macro expansion time) that all of the getters in head position
correspond to the same record type.
* test-suite/tests/srfi-9.test: Add test.
* module/srfi/srfi-9.scm (%define-record-type): Accept additional 'form'
parameter which contains the original form of 'define-record-type' or
'define-immutable-record-type'. Add elaborate pattern guard which
raises descriptive syntax errors for specific errors, and a fallback
pattern to catch anything else.
(define-record-type): Pass 'form' parameter to %define-record-type.
* module/srfi/srfi-9/gnu.scm (define-immutable-record-type): Pass 'form'
parameter to %define-record-type.
* test-suite/tests/srfi-9.test: Add tests.
Written in collaboration with Ludovic Courtès <ludo@gnu.org>
* module/srfi/srfi-9.scm: Internally, rename 'accessor' to 'getter'
and 'modifier' to 'setter'.
(define-tagged-inlinable, getter-type, getter-index, getter-copier,
%%on-error, %%set-fields): New macros.
(%define-record-type): New macro for creating both mutable and
immutable records, and containing a substantially rewritten version of
the code formerly in 'define-record-type'.
(define-record-type): Now just a wrapper for '%define-record-type'.
(throw-bad-struct, make-copier-id): New procedures.
* module/srfi/srfi-9/gnu.scm (define-immutable-record-type, set-field,
and set-fields): New exported macros.
(collate-set-field-specs): New procedure.
(%set-fields-unknown-getter, %set-fields): New macros.
* test-suite/tests/srfi-9.test: Add tests. Rename getters and setters
in existing tests to make the functional setters look better.
Fixed <http://bugs.gnu.org/11196>.
Reported by Klaus Stehle <klaus.stehle@uni-tuebingen.de>.
* module/srfi/srfi-9.scm (define-record-type): Define the contructor
before TYPE-NAME. Set RTD's constructor field.
* test-suite/tests/srfi-9.test ("record compatibility"): New test
prefix.
* module/srfi/srfi-9.scm (define-inlinable): When inlining, evaluate the
arguments only once. Reported by Andreas Rottmann; thanks to Andy
Wingo for the elegant solution.
* test-suite/tests/srfi-9.test ("side-effecting arguments"): New test
prefix.
The expansion of `define-inlinable' contained an expression, which made
SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition
used in expression context").
* module/srfi/srfi-9.scm (define-inlinable): Get rid of apparently
useless expression in the expansion, so the expansion yields only
definitions. At the same time, use a space in the generated names to
lessen the chances of name conflicts, also avoiding -Wunused-toplevel
warnings.
* test-suite/tests/srfi-9.test (non-toplevel): New test verifying that
`define-record-type' works in non-toplevel context as well.
* doc/ref/srfi-modules.texi (SRFI-9 - define-record-type): Add
subsubsection noting that Guile does not enforce top-levelness.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>