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

250 commits

Author SHA1 Message Date
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
54cbf8c6dc Merge remote-tracking branch 'origin/stable-2.0' 2012-11-08 19:29:56 -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
Mark H Weaver
fa980bcc0f Merge remote-tracking branch 'origin/stable-2.0'
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
2012-10-30 23:46:31 -04:00
Ludovic Courtès
e7350baf1e Rewrite SRFI-31 in terms of `syntax-rules'.
* 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.
2012-09-11 23:39:32 +02:00
Ian Price
d6bd182618 ISO 8601 time format specifies zero padding for hours, not blank padding.
* 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.
2012-08-27 00:10:44 +02:00
Andy Wingo
5f8d67ad09 simplify %condition-type-vtable
* module/srfi/srfi-35.scm (%condition-type-vtable): Use make-vtable
  instead of make-vtable-vtable.
2012-07-06 18:32:14 +02:00
Andy Wingo
0dd7c54075 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/deprecated.c
	libguile/ports.c
	libguile/ports.h
	libguile/strports.c
	test-suite/tests/cse.test
2012-06-22 13:18:02 +02:00
Ludovic Courtès
ecb48dccba Make SRFI-6 string ports Unicode-capable.
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.
2012-06-20 15:50:27 +02:00
Andy Wingo
e7501d4a68 Merge commit 'd10f7b572c'
Conflicts:
	libguile/smob.c
	libguile/smob.h
	test-suite/tests/tree-il.test
2012-04-26 22:17:47 +02: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
Andy Wingo
d489998364 Merge remote-tracking branch 'origin/stable-2.0'
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
2012-03-02 17:20:47 +01:00
Mark H Weaver
ef405f8ba7 Fix <TAG>vector-length when applied to other uniform vector types
* 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.
2012-03-01 16:16:18 -05:00
Andy Wingo
f9c3584117 srfi-18 cleanup
* module/srfi/srfi-18.scm (with-exception-handler):
  (thread-join!, mutex-lock!, mutex-unlock!): Avoid useless invocations
  of `apply'.
2012-02-24 19:42:00 +01:00
Andy Wingo
91ee7515da Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/__scm.h
	libguile/array-map.c
	libguile/procprop.c
	libguile/tags.h
	module/ice-9/deprecated.scm
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	test-suite/standalone/test-num2integral.c
	test-suite/tests/regexp.test
2012-01-10 00:41:42 +01:00
Ludovic Courtès
b3da54d181 Placate a number of `syntax-check' verifications.
- "filesystem" -> "file system"
  - remove doubled words
  - use EXIT_* macros instead of literal numbers
  - update `syntax-check' exclusion files
2012-01-05 23:38:10 +01:00
Andy Wingo
bfe35b90ff Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
2011-12-13 10:20:44 +01:00
Andy Wingo
9670f238d4 current-input-port et al are srfi-39 parameters
* 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.
2011-12-10 21:37:19 +01:00
Andy Wingo
b2208d2e98 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/fluids.c
	libguile/gc.c
	libguile/gc.h
	libguile/objcodes.c
	libguile/procprop.c
	libguile/vm.c
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
2011-12-01 23:31:50 +01:00
Andy Wingo
5139b7b928 simplify %condition-type-vtable
* module/srfi/srfi-35.scm (%condition-type-vtable): Use make-vtable
  instead of make-vtable-vtable.
2011-11-24 11:47:36 +01:00
Andy Wingo
9447207f0c Use default value for make-fluid in Scheme files
* module/ice-9/boot-9.scm (%exception-handler)
  (%running-exception-handlers, read-eval?, *repl-stack*)
  (make-mutable-parameter):
* module/ice-9/getopt-long.scm (%program-name):
* module/language/elisp/runtime.scm (built-in-macro, defspecial):
* module/srfi/srfi-39.scm (make-parameter/helper):
* module/system/base/language.scm (*current-language*):
* module/system/base/message.scm (*current-warning-port*):
  (*current-warning-prefix*):
* module/system/base/target.scm (%target-type, %target-endianness)
  (%target-word-size):
* module/texinfo/plain-text.scm (*indent*, *itemizer*):
* benchmark-suite/lib.scm (prefix-fluid):
* test-suite/lib.scm (prefix-fluid): Give fluids a useful default
  value.
2011-11-23 12:54:09 +01:00
Andy Wingo
df08fc359c fix srfi-67 compilation
* module/srfi/srfi-67/compare.scm: Fix define-syntax-rule conversion.
2011-09-02 19:49:26 +02:00
Andy Wingo
0c65f52c6d more define-syntax-rule usage
* 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-09-02 11:36:14 +02:00
Andy Wingo
6ffb5f9765 check that srfi-1 procedure arguments are procedures
* 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.
2011-08-17 23:09:39 +02:00
Andy Wingo
8761623524 srfi-9 record compatibility with boot-9 records
* 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.
2011-08-17 10:47:04 +02:00
Andy Wingo
e7a81c7acd fix take-right and drop-right for improper lists
* 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.
2011-08-12 23:26:15 +02:00
Andy Wingo
abab34ce4d srfi-19 refactor
* 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.
2011-08-04 12:53:07 +02:00
Andy Wingo
b706a01129 fix srfi-1 map-in-order definition
* 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.
2011-05-07 11:31:38 +02:00
Andy Wingo
a2230b653b map and for-each in scheme
* 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.
2011-05-05 23:07:37 +02:00
Andy Wingo
9e775af3bf srfi-1 `member' in scheme, inlines to memq / memv in some cases
* 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.
2011-05-05 12:59:07 +02:00
Ludovic Courtès
756b1dfa6e Keep a 2.0.0-compatible `define-inlinable' macro in (srfi srfi-9).
Partially reverts 165b10ddfa and
531c9f1dc5.

* module/srfi/srfi-9.scm (define-inlinable): New macro.
2011-04-27 22:26:05 +02:00
Andreas Rottmann
165b10ddfa Move `define-inlinable' into the default namespace
* 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'.
2011-04-07 01:12:26 +02:00
Andy Wingo
39bed56f67 fix c32vector-set!, c64vector-set!
* module/srfi/srfi-4/gnu.scm (bytevector-c32-native-set!):
  (bytevector-c64-native-set!): Fix to actually allow complex numbers.

* test-suite/tests/srfi-4.test: Add tests.
2011-04-01 16:45:58 +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
3df539b1a5 Get rid of `define-macro' in the SRFI 26 implementation
* 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>
2010-12-07 23:13:55 +01:00
Andreas Rottmann
12708eeb11 Add implementation of SRFI 38
* 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>
2010-11-03 00:19:54 +01:00
Andreas Rottmann
5efcd34d71 Extend the #:replace list of the SRFI 69 module
* module/srfi/srfi-69.scm: Add `make-hash-table' and `hash-table?' to
  the #:replace list of the module definition.
2010-10-27 23:33:40 +02:00
Andy Wingo
df6336c0a0 re-implement srfi-34's guard with syntax-case
* module/srfi/srfi-34.scm (guard): Re-implement using syntax-case.
2010-10-14 16:13:57 +02:00
Ludovic Courtès
7f593bc7f9 SRFI-1: Rewrite split-at' and split-at!' in Scheme.
This partially reverts commit bb560b9c16
(Tue Mar 15 2005).

* module/srfi/srfi-1.scm (out-of-range, split-at, split-at!): New
  procedures.

* libguile/srfi-1.c (scm_srfi1_split_at, scm_srfi1_split_at_x): Remove.
* libguile/srfi-1.h (scm_srfi1_split_at, scm_srfi1_split_at_x): Ditto.
2010-10-08 15:25:56 +02:00
Ludovic Courtès
58ee1beabe SRFI-1: Rewrite `filter-map' in Scheme.
This partially reverts commit c16359466b
(Thu Mar 17 2005).

* libguile/srfi-1.c (scm_srfi1_filter_map): Remove.
* libguile/srfi-1.h (scm_srfi1_filter_map): Ditto.

* module/srfi/srfi-1.scm (filter-map): New procedure.
2010-10-08 15:25:56 +02:00
Ludovic Courtès
a6505cb49c SRFI-1: Make `fold-right' tail-recursive.
* module/srfi/srfi-1.scm (fold-right): Make tail-recursive.

* test-suite/tests/srfi-1.test ("fold-right"): New test prefix.
2010-10-08 15:25:56 +02:00
Ludovic Courtès
07076c1e61 SRFI-1: Make `unfold' tail-recursive (fix bug #30071).
* 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.
2010-10-08 15:25:56 +02:00
Andreas Rottmann
f16a20071d Add implementation of SRFI 45
* module/srfi/srfi-45.scm: New file, containing the reference implementation of
  SRFI 45, slightly adapted to use SRFI-9.
* module/Makefile.am (SRFI_SOURCES): Added srfi/srfi-45.scm.

* test-suite/tests/srfi-45.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add tests/srfi-45.test.

* doc/ref/srfi-modules.texi (SRFI-45): New node and subsection;
  essentially a shortended transcript of the SRFI-45 specification.
2010-10-03 21:54:22 +02:00
Andy Wingo
eb0b45facc srfi-67 #:replace work
* module/srfi/srfi-67.scm (string-compare, string-compare-ci): #:replace
  these bindings.
2010-10-03 12:18:14 +02:00
Andreas Rottmann
8175a07e34 Add implementation of SRFI-67
* module/srfi/srfi-67/compare.scm: New file; reference implementation of
  SRFI 67.
* module/srfi/srfi-67.scm: New module; includes the refernce
  implementation.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-67.scm.
  (NOCOMP_SOURCES): Add srfi/srfi-67/compare.scm.

* test-suite/tests/srfi-67.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add tests/srfi-67.test.
2010-10-03 12:14:21 +02:00
Andreas Rottmann
fdc8fd46fd Add implementation of SRFI 42
* module/srfi/srfi-42/ec.scm: New file; reference implementation of
  SRFI 42.
* module/srfi/srfi-42.scm: New file; module for SRFI 42.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-42.scm.
  (NOCOMP_SOURCES): Add srfi/srfi-42/ec.scm.

* test-suite/tests/srfi-42.test: New file; test suite for SRFI 42.
* test-suite/Makefile.am: SCM_TESTS: Add tests/srfi-42.test.
2010-10-03 12:09:50 +02:00
Andreas Rottmann
56ec46a7c3 Add implementation of SRFI 27
* module/srfi/srfi-27.scm: New file; implementation of SRFI 27 in terms
  of the existing random number generator.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-27.scm.

* test-suite/tests/srfi-27.test: New file; minimal test suite for SRFI 27.
* test-suite/Makefile.am (SCM_TESTS): Add tests/srfi-27.test.

* doc/ref/srfi-modules.texi: Add subsection on SRFI-27 based
  on the specification.
2010-09-27 22:15:51 +02:00
Ludovic Courtès
194865d2f7 SRFI-1: Rewrite `alist-copy' in Scheme.
This partially reverts commit b1fff4e793
(Sat Apr 2 2005).

* libguile/srfi-1.c (scm_srfi1_alist_copy): Remove.
* libguile/srfi-1.h (scm_srfi1_alist_copy): Remove declaration.

* module/srfi/srfi-1.scm (alist-copy): New procedure.
2010-09-20 00:01:23 +02:00
Andy Wingo
37710f7e8f move srfi-1 and srfi-60 C impl to libguile, without public C api
* libguile/srfi-1.c:
* libguile/srfi-1.h:
* libguile/srfi-60.c:
* libguile/srfi-60.h:
* libguile/ChangeLog-srfi: Move here, from the srfi/ dir. The C API is
  internal. Add API to register the extensions, called by init.c.

* libguile/init.c: Verily, register srfi extensions.

* libguile/Makefile.am: Add srfi files.

* module/srfi/srfi-1.scm:
* module/srfi/srfi-60.scm: Update load-extension invocation.

* Makefile.am:
* configure.ac: Remove srfi/ dir.

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-srfi-1.c: Remove srfi-1 C test, we don't
  support this API any more.
2010-09-12 23:29:11 +02:00