1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

19 commits

Author SHA1 Message Date
Mark H Weaver
361553b49d Adapt srfi-9.test to error reporting improvements; update copyright dates.
* module/srfi/srfi-9.scm: Add 2013 copyright date.

* test-suite/tests/srfi-9.test: Adapt to recent error reporting
  improvements to procedures defined by 'define-tagged-inlinable'.
2013-09-12 18:14:54 -04:00
Mark H Weaver
b594998356 srfi-9.test: avoid symbols of the form ':bar' for more robust checking.
* 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.
2012-11-10 19:14:08 -05:00
Mark H Weaver
3d01c19a78 Change the argument order of 'set-fields' to match that of 'set-fields'.
* module/srfi/srfi-9/gnu.scm (set-fields): Swap order of first two
  arguments.

* test-suite/tests/srfi-9.test: Update tests.
2012-11-10 16:05:24 -05:00
Mark H Weaver
92fac8c056 Improve error for set-fields paths leading to different types.
* 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.
2012-11-10 01:37:20 -05:00
Mark H Weaver
f31a076232 Improve error messages for invalid record definitions.
* 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.
2012-11-09 23:05:42 -05:00
Mark H Weaver
dfba1025e5 Fix non-toplevel srfi-9 compile-time error tests to actually be non-toplevel.
* test-suite/tests/srfi-9.test: Move non-toplevel record definitions to be
  within the expression passed to 'compile'.
2012-11-09 23:02:44 -05:00
Mark H Weaver
ce6508531c Use 'pass-if-equal' to check syntax-error exceptions in srfi-9.test.
* test-suite/tests/srfi-9.test: Convert detailed syntax-error exception
  tests to use 'pass-if-equal'.
2012-11-09 22:59:12 -05:00
Mark H Weaver
d9e368979b Implement functional record setters.
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.
2012-11-08 19:20:28 -05:00
Ludovic Courtès
5ef102cc93 SRFI-9: Set the `record-constructor' slot of the RTD.
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.
2012-04-10 00:17:39 +02:00
Ludovic Courtès
b075a6d766 Fix `define-inlinable' in SRFI-9 so that arguments are evaluated only once.
* 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.
2011-03-11 21:02:30 +01:00
Andreas Rottmann
531c9f1dc5 Don't mix definitions and expressions in SRFI-9
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>
2011-03-09 21:36:54 +01:00
Andreas Rottmann
c4a8200fa0 Fix SRFI-9 for records without fields
* module/srfi/srfi-9.scm (define-record-type): Deal with fieldless records.
* test-suite/tests/srfi-9.test: Add a fieldless record definition.
2010-06-19 14:52:56 +02:00
Ludovic Courtès
30a700c8c1 Inline SRFI-9 constructors too.
* module/srfi/srfi-9.scm (define-record-type)[constructor]: Use
  `define-inlinable' instead of `define'.

* test-suite/lib.scm (exception:syntax-pattern-unmatched): New variable.

* test-suite/tests/srfi-9.test ("constructor")["foo 0 args (inline)",
  "foo 2 args (inline)"]: New tests.
  ["foo 0 args", "foo 2 args"]: Adjust to constructor inlining.

* testsuite/t-records.scm: Remove wrong-arg-count case.
2010-02-01 00:25:51 +01:00
Neil Jerram
53befeb700 Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
   module/srfi/*.scm
   module/rnrs/*.scm
   module/scripts/*.scm
   testsuite/*.scm
   guile-readline/*
)
2009-06-17 00:22:09 +01:00
Ludovic Courtès
3ba9acb1b4 Changes from arch/CVS synchronization 2007-08-08 14:56:02 +00:00
Kevin Ryde
8ab3d8a068 merge from 1.8 branch 2006-10-09 23:40:48 +00:00
Kevin Ryde
6e7d5622ee merge from 1.8 branch 2006-04-16 23:37:40 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Martin Grabmüller
f764e6d10d * tests/srfi-10.test: New file.
* tests/srfi-9.test: New file.

	* tests/srfi-13.test: Added some more tests.
2001-05-10 13:52:27 +00:00