* module/srfi/srfi-9/gnu.scm (set-record-type-printer!): Change the
parameter name to `proc'.
* doc/ref/api-compound.texi (SRFI-9 Records): Update accordingly.
* 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.
Moved scm_i_struct_hash from struct.c to hash.c and made it static.
The port's alist is now a field of 'scm_t_port'.
Conflicts:
libguile/arrays.c
libguile/hash.c
libguile/ports.c
libguile/print.h
libguile/read.c
* module/srfi/srfi-31.scm: Use `#:export' instead of `#:export-syntax'.
(rec): Rewrite using `syntax-rules'.
* test-suite/tests/srfi-31.test ("rec special form"): Change exception
type to EXCEPTION:SYNTAX-PATTERN-UNMATCHED.
* doc/ref/srfi-modules.texi ("SRFI-19 Date to string"): Fix iso 8601 format strings.
* module/srfi/srfi-19.scm (directives): Fix iso 8601 format strings.
Partly addresses <http://bugs.gnu.org/11197>.
Reported by Klaus Stehle <klaus.stehle@uni-tuebingen.de>.
* module/srfi/srfi-6.scm (open-input-string, open-output-string): New
procedures.
* test-suite/tests/srfi-6.test ("open-input-string")["read-char,
Unicode"]: New test.
("open-output-string")["λ"]: New test.
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.
There are a some failures currently:
FAIL: tree-il.test: warnings: format: non-literal format string with forward declaration
ERROR: srfi-18.test: current-exception-handler: current handler returned at top level - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
ERROR: srfi-18.test: current-exception-handler: multiple levels of handler nesting - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
ERROR: srfi-18.test: current-exception-handler: exception handler installation is thread-safe - arguments: ((wrong-type-arg "car" "Wrong type argument in position ~A (expecting ~A): ~S" (1 "pair" #<unspecified>) (#<unspecified>)))
Conflicts:
module/language/tree-il/peval.scm
module/language/tree-il/primitives.scm
test-suite/tests/tree-il.test
* module/srfi/srfi-4.scm, module/srfi/srfi-4/gnu.scm
(define-bytevector-type): Fix definition of <TAG>vector-length when
applied to uniform vectors of different element sizes. Thanks to
Tobias Brandt <tob.brandt@googlemail.com> for reporting this bug.
* test-suite/tests/srfi-4.test: Add tests.
* libguile/ports.c (scm_init_ports): Export the port fluids to Scheme,
temporarily.
* module/ice-9/boot-9.scm (fluid->parameter): Turn `current-input-port'
et al into srfi-39 parameters, backed by the exported fluids, then
remove the fluids from the guile module.
(%cond-expand-features): Add srfi-39.
* module/srfi/srfi-39.scm: Re-export features from boot-9.
* test-suite/tests/parameters.test: Add tests.
* module/srfi/srfi-1.scm (check-arg, wrong-type-arg): Refactor arg type
checkers to be macros, and do the minimal amount of work in the
functions themselves. Use these checkers consistently for all
procedure arguments in this module. This catches user errors early;
see bug 33628.
* module/srfi/srfi-9.scm (define-record-type): Instead of defining the
RTD using make-vtable, use make-struct with the record-type-vtable,
and record the type name and fields names in the vtable. This way
SRFI-9 records are compatible with boot-9 records. Also we use a
generic printer, instead of generating one anew.
* libguile/srfi-1.h:
* libguile/srfi-1.c (scm_srfi1_drop_right, scm_srfi1_take_right): Remove
these internal functions, replacing with Scheme implementations.
* module/srfi/srfi-1.scm (take-right, drop-right): Add these impls from
the reference code. They do the right thing for improper lists,
according to the spec, but they diverge for circular lists. Oh well.
* test-suite/tests/srfi-1.test ("drop-right", "take-right"): Add more
tests.
* module/srfi/srfi-19.scm (priv:locale-number-separator, priv:locale-am)
(priv:locale-am): Inline definitions.
Strip priv: prefix from module vars, as it's unnecessary, except for
in a couple cases.
* module/srfi/srfi-1.scm (map-in-order): As we are not extending the
core `map' binding, actually make a new `map-in-order' alias here.
Fixes fresh builds.
* module/ice-9/boot-9.scm (map, for-each): Implement in Scheme instead
of C. There are boot versions before `cond' is defined.
(map-in-order): Define this alias here instead of in evalext.h.
* libguile/eval.c: Stub out the map and for-each definitions to just
call into Scheme.
* libguile/evalext.c: Remove map-in-order definition.
* module/srfi/srfi-1.scm: Replace all calls to map1 with calls to map.
(map, for-each): Define implementations here, in Scheme, instead of in
C.
* test-suite/tests/eval.test (exception:wrong-length, "map"): Update the
expected exception for mapping over lists of different lengths.
* libguile/srfi-1.h:
* libguile/srfi-1.c: Remove map and for-each definitions. Remove the
bit that extended the core `map' primitive with another method: the
right way to do that is with modules.
* libguile/srfi-1.c:
* libguile/srfi-1.h (scm_srfi1_member): Move implementation to Scheme.
* module/srfi/srfi-1.scm (member): Implement here, with the inlining
cases for eq? and eqv?. Speeds up a compiled bootstrap of
psyntax.scm, because lset-adjoin inlines to the memq case.
(lset<=): Reindent.
(lset-adjoin, lset-union): If the comparator is eq? or eqv?, just pass
it through to `member', so we inline to memq / memv. Use something
closer to the reference implementations.
* module/ice-9/boot-9.scm (define-inlineable): Moved here from SRFI-9.
* module/srfi/srfi-9 (define-inlinable): Removed here.
* doc/ref/api-procedures.texi (Inlinable Procedures): Add subsection
about `define-inlinable'.
* 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>
* module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'.
The new implementation is mostly just a transcription of the old code;
the reference implementation which relies only on `syntax-rules' may
(or may not) be considered more elegant :-).
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/srfi/srfi-38.scm: New file, partly based on the reference
implementation and on Alex Shinn's public-domain implementation for
Chicken.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-38.scm.
* test-suite/tests/srfi-38.test: New file, minimal test suite for SRFI
38.
* test-suite/Makefile.am (SCM_TESTS): Added tests/srfi-38.test.
* doc/ref/srfi-modules.texi: Add a node for SRFI 38.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* module/srfi/srfi-1.scm (unfold): Make tail-recursive, following a
suggestion by Szavai Gyula.
* test-suite/tests/srfi-1.test ("unfold"): New test prefix.