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

47 commits

Author SHA1 Message Date
Rob Browning
6338459159 Drop libguile srfi-1
...now that all of the C code has been migrated to Scheme.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
remove srfi-1.c.
(DOC_X_FILES): Remove srfi-1.x.
(DOT_DOC_FILES): Remove srfi-1.doc.
(modinclude_HEADERS): Remove srfi-1.h.
* libguile/init.c (scm_i_init_guile): Don't call scm_register_srfi_1.
* libguile/srfi-1.c: Remove.
* libguile/srfi-1.h: Remove.
* module/srfi/srfi-1.scm: Don't load srfi-1 from libguile.
2024-07-30 19:39:32 -05:00
Rob Browning
51b7021de1 srfi-1 delete-duplicates: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_delete-duplicates): delete.
* libguile/srfi-1.h (scm_srfi1_delete-duplicates): delete.
* module/srfi/srfi-1.scm: add delete-duplicates.
2024-07-30 19:28:37 -05:00
Rob Browning
a94b4406b7 srfi-1 delete-duplicates!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_delete-duplicates_x): delete.
* libguile/srfi-1.h (scm_srfi1_delete-duplicates_x): delete.
* module/srfi/srfi-1.scm: add delete-duplicates!.
2024-07-30 19:28:37 -05:00
Rob Browning
51e15d448f srfi-1 lset-difference: use remove
* module/srfi/srfi-1.scm (lset-difference): rely on remove like
lset-difference!; in addition to being simpler, this allows sharing a
common tail.
2024-07-30 19:28:37 -05:00
Rob Browning
945c97b14d srfi-1 lset-difference!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_lset-difference_x): delete.
* libguile/srfi-1.h (scm_srfi1_lset-difference_x): delete.
* module/srfi/srfi-1.scm: add lset-difference!.
* test-suite/tests/srfi-1.test: extend lset-difference! tests to cover
lset-difference.
2024-07-30 19:28:37 -05:00
Rob Browning
3eb6afe738 srfi-1 partition!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_partition_x): delete.
* libguile/srfi-1.h (scm_srfi1_partition_x): delete.
* module/srfi/srfi-1.scm: add partition!.
2024-07-30 19:28:37 -05:00
Rob Browning
925faf1f01 srfi-1 partition: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_partition): delete.
* libguile/srfi-1.h (scm_srfi1_partition): delete.
* module/srfi/srfi-1.scm: add partition.
2024-07-30 19:28:37 -05:00
Rob Browning
58246aee24 srfi-1 count: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_count): delete.
* libguile/srfi-1.h (scm_srfi1_count): delete.
* module/srfi/srfi-1.scm: add count.
2024-07-30 19:28:37 -05:00
Rob Browning
372a52e6aa srfi-1 length+: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_length_plus): delete.
* libguile/srfi-1.h (scm_srfi1_length_plus): delete.
* module/srfi/srfi-1.scm: add length+.
2024-07-30 19:28:37 -05:00
Rob Browning
3cb6309f62 srfi-1 append-reverse!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_append_reverse_x): delete.
* libguile/srfi-1.h (scm_srfi1_append_reverse_x): delete.
* module/srfi/srfi-1.scm: add append-reverse!.
2024-07-30 19:28:37 -05:00
Rob Browning
17281519df srfi-1 append-reverse: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_append_reverse): delete.
* libguile/srfi-1.h (scm_srfi1_append_reverse): delete.
* module/srfi/srfi-1.scm: add append-reverse.
2024-07-30 19:11:34 -05:00
Rob Browning
c62d2962d4 srfi-1 concatenate concatenate!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* libguile/srfi-1.h (scm_srfi1_concatenate, scm_srfi1_concatenate_x): delete.
* module/srfi/srfi-1.scm: add concatenate and concatenate!.
2024-07-30 18:54:45 -05:00
Rob Browning
a816b2484b srfi-1 delete delete!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_delete, scm_srfi1_delete_x): delete.
* libguile/srfi-1.h (scm_srfi1_delete, scm_srfi1_delete_x): delete.
* module/srfi/srfi-1.scm: add delete and delete!.
2024-07-30 18:54:45 -05:00
Rob Browning
c5f26d4c27 srfi-1 remove!: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_remove_x): delete.
* libguile/srfi-1.h (scm_srfi1_remove_x): delete.
* module/srfi/srfi-1.scm: add remove!.
2024-07-30 18:54:45 -05:00
Rob Browning
03d4a3b5df srfi-1 remove: move from C to Scheme
The Scheme implementation is an adapted version of the approach used by
delete-duplicates, which allows sharing any common tail.

* libguile/srfi-1.c (scm_srfi1_remove): delete.
* libguile/srfi-1.h (scm_srfi1_remove): delete.
* module/srfi/srfi-1.scm: add remove.
2024-07-30 18:54:45 -05:00
Rob Browning
aa44035ee8 srfi-1 list-copy: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_list_copy): delete.
* libguile/srfi-1.h (scm_srfi1_list_copy): delete.
* module/srfi/srfi-1.scm: add list-copy.
* test-suite/tests/srfi-1.test: ensure copied spine is independent.
2024-07-30 18:54:45 -05:00
Ludovic Courtès
e304773416 srfi-1: 'find-tail' passes 'check-arg' the right procedure name.
* module/srfi/srfi-1.scm (find-tail): Pass 'find-tail' as the 3rd
argument to 'check-arg'.
2021-09-20 17:00:19 +02:00
Ludovic Courtès
a15acbb828 srfi-1: Rewrite 'assoc' in Scheme.
* libguile/srfi-1.c (scm_srfi1_assoc): Remove.
* libguile/srfi-1.h (scm_srfi1_assoc): Likewise.
* module/srfi/srfi-1.scm (assoc): New procedure.
2020-06-17 17:59:35 +02:00
Ludovic Courtès
cd4c747fb8 srfi-1: Rewrite 'find-tail' in Scheme.
* libguile/srfi-1.c (scm_srfi1_find_tail): Remove.
* libguile/srfi-1.h (scm_srfi1_find_tail): Likewise.
* module/srfi/srfi-1.scm (find-tail): New procedure.
2020-06-17 17:33:28 +02:00
Ludovic Courtès
0360843ace srfi-1: Rewrite 'find' in Scheme.
This halves the wall-clock time of:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find zero? lst)'

and yields an 18% speedup on:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find (lambda (x) (= 2 x)) lst)'

* libguile/srfi-1.c (scm_srfi1_find): Remove.
* libguile/srfi-1.h (scm_srfi1_find): Likewise.
* module/srfi/srfi-1.scm (find): New procedure.
* doc/ref/srfi-modules.texi (SRFI-1 Searching): Adjust docstring.
2020-06-17 17:25:23 +02:00
Daniel Llorens
2b6083865a Single definition of (iota)
* module/ice-9/boot-9.scm (iota): Fix to be SRFI-1 compatible.
* module/srfi/srfi-1.scm: Re-export iota.
2019-12-06 14:14:30 +01:00
Andy Wingo
9de674e6e6 Rewrite boot-9 map to be recursive and pure
* module/ice-9/boot-9.scm (map): Rewrite to be recursive and pure
  instead of iterative and effectful.  At best this is faster; at worst
  it is slower.  In any case it resolves continuation-related issues.

* module/srfi/srfi-1.scm (fold): Specialize the two-arg case.
  (map): Rewrite to be recursive.

* test-suite/tests/r5rs_pitfall.test (8.3): Update for new expected map
  behavior.
2014-05-01 21:17:28 +02:00
Andy Wingo
f082c5f30a Optimize two-list srfi-1 map
* module/srfi/srfi-1.scm (map): Optimize the two-list variant.
2014-04-01 20:52:15 +02:00
Andy Wingo
4926024cfb Simplify boot-9 and srfi-1 map
* module/ice-9/boot-9.scm (map):
* module/srfi/srfi-1.scm (map): Simplify the implementations to check
  for list? beforehand.  It's faster, and it will be needed if we decide
  to go recursive.
2014-03-31 18:21:04 +02:00
Andy Wingo
f883ae59a0 Optimize srfi-1 for-each with two lists.
* module/srfi/srfi-1.scm (for-each): Optimize for the two-list case.
2014-03-16 19:58:30 +01:00
Andy Wingo
f87a7327a5 More for-each micro-optimizations
* module/ice-9/boot-9.scm (for-each):
* module/srfi/srfi-1.scm (for-each): Re-implement one-list case using an
  explicit check for list? instead of the tortoise-hare thing.  Seems to
  be faster!
2014-03-16 19:41:51 +01:00
Andy Wingo
3c3de73d4d Port unrolled one-argument for-each from boot-9 to srfi-1
* module/srfi/srfi-1.scm (for-each): Port unrolled one-argument
  implementation here from the boot-9 version.
2014-03-02 12:05:32 +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
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
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
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
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
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
Ludovic Courtès
dcde43869a SRFI-1: Rewrite drop-right!', drop-while', `reduce', etc. in Scheme.
This partially reverts commit e9508fbb7d
(May 3 2005).

* module/srfi/srfi-1.scm (take!, drop-right!, reduce, reduce-right,
  take-while, take-while!, drop-while, span, span!, lset-adjoin): New
  procedures.

* srfi/srfi-1.c (scm_srfi1_drop_right_x, scm_srfi1_drop_while,
  scm_srfi1_lset_adjoin, scm_srfi1_reduce, scm_srfi1_reduce_right,
  scm_srfi1_span, scm_srfi1_span_x, scm_srfi1_take_x,
  scm_srfi1_take_while, scm_srfi1_take_while_x): Rewrite as
  proxies to the corresponding Scheme procedures.

* benchmark-suite/benchmarks/srfi-1.bm ("drop-while"): New benchmark
  prefix.
2010-09-02 00:03:07 +02:00
Ludovic Courtès
b86d230932 SRFI-1: Rewrite break' and break!' in Scheme.
This partially reverts commit 6e9f3c2676
(Tue May 3 2005).

* module/srfi/srfi-1.scm (break, break!): New procedures.

* srfi/srfi-1.c (scm_srfi1_break, scm_srfi1_break_x): Rewrite as
  proxies to the corresponding Scheme procedures.

* test-suite/standalone/test-srfi-1.c (failure): New function.
  (tests): Add `scm_srfi1_break' test.  Use `failure'.
2010-08-27 18:59:42 +02:00
Ludovic Courtès
d7418e60a5 SRFI-1: Rewrite fifth', sixth', etc. in Scheme.
This partially reverts commit 03731332d5
(Tue May 3 2005).

* module/srfi/srfi-1.scm (fifth, sixth, seventh, eighth, ninth, tenth):
  New procedures.

* srfi/srfi-1.c (scm_srfi1_fifth, scm_srfi1_sixth, scm_srfi1_seventh,
  scm_srfi1_eighth, scm_srfi1_ninth, scm_srfi1_tenth): Rewrite as
  proxies to the corresponding Scheme procedure.

* test-suite/tests/srfi-1.test ("eighth")["() -1"]: Change exception
  type to `exception:wrong-type-arg'.
  ("fifth")["() -1"]: Likewise.
  ("ninth")["() -1"]: Likewise.
  ("seventh")["() -1"]: Likewise.
  ("sixth")["() -1"]: Likewise.
  ("tenth")["() -1"]: Likewise.
2010-08-27 18:59:42 +02:00
Ludovic Courtès
0b7f2eb8bf Start rewriting SRFI-1 in Scheme.
This partially reverts commit e556f8c3c6
(Fri May 6 2005).

* module/srfi/srfi-1.scm (xcons, list-tabulate, not-pair?, car+cdr,
  last, fold, list-index): New procedures.

* srfi/srfi-1.c (srfi1_module): New variable.
  (CACHE_VAR): New macro.
  (scm_srfi1_car_plus_cdr, scm_srfi1_fold, scm_srfi1_last,
  scm_srfi1_list_index, scm_srfi1_list_tabulate, scm_srfi1_not_pair_p,
  scm_srfi1_xcons): Rewrite as proxies of the corresponding Scheme
  procedure.

* test-suite/tests/srfi-1.test ("list-tabulate")["-1"]: Change exception
  type to `exception:wrong-type-arg'.

* benchmark-suite/benchmarks/srfi-1.bm: New file.

* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add
  `benchmarks/srfi-1.bm'.

* test-suite/standalone/Makefile.am (test_srfi_1_SOURCES,
  test_srfi_1_CFLAGS, test_srfi_1_LDADD): New variables.
  (check_PROGRAMS): Add `test-srfi-1'.
  (TESTS): Ditto.

* test-suite/standalone/test-srfi-1.c: New file.
2010-07-21 01:07:56 +02:00
Ludovic Courtès
2cf7ff2e79 SRFI-1: Use the built-in optional argument support.
* module/srfi/srfi-1.scm (iota, unfold, unfold-right, alist-delete,
  alist-delete!): Use `define*' and optional arguments instead of rest
  arguments.
2009-12-11 15:20:12 +01:00
Neil Jerram
83ba2d3750 Complete changing license to LGPLv3+
(Still guile-readline to do, but that will all be GPLv3+.)
2009-06-17 22:30:26 +01:00
Andy Wingo
ea93465de7 move scm srfi files to module/srfi, and compile them.
* .gitignore: Add gdb-pre-inst-guile.

* configure.in: Add module/srfi/Makefile.

* module/Makefile.am: Add srfi/.

* module/srfi/: SRFI scheme files moved here, and compiled.

* srfi/Makefile.am: Remove the bits about the scheme files.
2008-11-01 13:49:23 +01:00
Renamed from srfi/srfi-1.scm (Browse further)