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

4563 commits

Author SHA1 Message Date
Andy Wingo
60d852248f <lambda-case> must have list of optargs
Before, the optional args in a lambda-case could be #f or a list of
symbols.  However the list of symbols is entirely sufficient; no
optional args means a null list.  Change everywhere that produces
lambda-case, matches on lambda-case, and reads deserialized lambda-case.
2024-08-29 09:53:37 +02:00
Andy Wingo
a970ed5bd5 Update psyntax copyright notice
* module/ice-9/psyntax.scm: Use the newer LGPLv3 header.  Add FSF
copyright lines for each year the file was modified.  Remove inline
changelogs.  Remove some comments describing psyntax in other Scheme
implementations.
2024-08-26 09:51:53 +02:00
Andy Wingo
d0790d766b Fix intset-fold-right on transient intsets
* module/language/cps/intset.scm (make-intset-folder): intset-fold-right
on a transient intset would dispatch to left fold after making the
persistent set.  Sadness!
2024-08-15 12:18:02 +02:00
Andy Wingo
7aa4cfa9de More thorough lowering of lognot to CPS
* module/language/tree-il/compile-cps.scm (canonicalize): Lower to a
logxor with -1.
2024-08-13 13:40:45 +02:00
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
Rob Browning
d99ae68f88 define-meta-command: mention effects of a missing category
module/system/repl/command.scm: add comment.
2024-07-12 17:49:45 -05:00
Maxim Cournoyer
522f368719 bug#71304: [PATCH] Add support for 'else' clause in R7RS cond-expand.
* module/ice-9/r7rs-libraries.scm (define-library)
<handle-cond-expand>: Add a pattern to match an 'else' clause.

Series-to: bug-guile@gnu.org
2024-07-01 23:38:01 +02:00
Andy Wingo
1120efe375 Fix race in check-guile to make needless guile-procedures symlink
* check-guile.in (top_srcdir): Don't try to make guile-procedures.tx, as
this races with multiple checkers, and it's gross.
* meta/uninstalled-env.in (GUILE_DOCSTRINGS_PATH): Instead when
uninstalled, use this variable.
* module/ice-9/documentation.scm (documentation-files): Remove the
current directory from the search path for documentation files; this was
always a hack.  Instead allow GUILE_DOCSTRINGS_PATH to override the
built-in search path.
2024-06-23 11:13:18 +02:00
Andy Wingo
8b324bef74 Remove dead code in resolve-interface
* module/ice-9/boot-9.scm (resolve-interface): Remove dead code.
2024-06-20 13:51:59 +02:00
Ludovic Courtès
461ff313fa
Rewrite ‘get-bytevector-all’ in Scheme.
* libguile/r6rs-ports.c (get_bytevector_all_var): New variable.
(init_bytevector_io_vars): New function.
(scm_get_bytevector_all): Rewrite as a proxy to ‘get-bytevector-all’
from (ice-9 binary-port).
* module/ice-9/binary-ports.scm (get-bytevector-all): New procedure.
* NEWS: Update.

Reported-by: Christopher Baines <mail@cbaines.net>
2024-06-16 15:05:09 +02:00
Ludovic Courtès
27feb2bfd3
wisp: Use uninterned symbols instead of UUIDs.
As suggested in
<https://lists.gnu.org/archive/html/guile-devel/2023-06/msg00008.html>.

* module/language/wisp.scm (wisp-uuid): Remove.
(repr-quote, repr-unquote, repr-quasiquote, repr-unquote-splicing)
(repr-syntax, repr-unsyntax, repr-quasisyntax, repr-unsyntax-splicing):
Turn into uninterned symbols.
(line-continues?, chunk-ends-with-period,
line-code-replace-inline-colons): Adjust comparisons accordingly.
(wisp-replace-paren-quotation-repr)[pred]: New procedure.
Use it to compare against the various ‘repr-’ values.
(wisp-make-improper)[dot?]: New procedure.
Use it to compare against ‘repr-dot’.
2024-06-01 11:50:16 +02:00
Arne Babenhauserheide
dce65edbaf
Add language/wisp, Wisp tests, and SRFI-119 documentation
* doc/ref/srfi-modules.texi (srfi-119): add node
* module/language/wisp.scm: New file.
* module/language/wisp/spec.scm: New file.
* test-suite/tests/srfi-119.test: New file.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-06-01 11:50:16 +02:00
Rob Browning
779a83d9c6 make-foreign-object-type: add #:super to provide superclasses
* module/system/foreign-object.scm (make-foreign-object-type): allow
specification of superclasses via #:super.
2024-05-17 12:53:39 -05:00
Michael Käppler
80d4055e42
Fix error messages containing format strings
The builtin primitive procedure `error` takes an optional message and
a list of arguments to include into the error message.
These args are formatted with `~S` and appended to the error message, so
that an example call of

`(error "Wrong argument: " 42)`

results in the output

"Wrong argument: 42"

If format strings occur in the message itself, however, they are
escaped. Thus a call like

`(error "Wrong argument: ~a" 42)`

is rendered as

"Wrong argument: ~a 42"

Some callers did not take this behavior into account, leading to
confusing error messages.
Changing the behavior of `error` to be
both backwards-compatible and accept also format strings inside messages
is not straightforward, because it would have to handle escaped `~`
characters as well. Therefore, fix `error` call sites using format
strings to use `format` before calling out to `error`.

The following files are affected:

* module/ice-9/format.scm (format)
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface)
* module/oop/goops.scm (make)
* module/srfi/srfi-37.scm (Comment at the beginning of file)
* module/system/base/compile.scm (call-once)
* module/system/repl/command.scm (break, tracepoint)
* module/system/repl/common.scm (repl-default-options)
* module/system/vm/traps.scm (arg-check, trap-at-source-location)

There are a couple of further call sites that were left unchanged,
either because they are using their own `error` procedure:

* module/ice-9/read.scm
* module/ice-9/command-line.scm

or are not referenced from other modules:

* module/system/base/lalr.upstream.scm:
* module/sxml/upstream/assert.scm:
* module/sxml/sxml-match.ss:

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Morgan Smith
f27e8b855f
Fix typos throughout codebase.
* NEWS:
* doc/ref/api-control.texi:
* doc/ref/api-data.texi:
* doc/ref/api-debug.texi:
* doc/ref/api-deprecated.texi:
* doc/ref/api-evaluation.texi:
* doc/ref/api-foreign.texi:
* doc/ref/api-i18n.texi:
* doc/ref/api-io.texi:
* doc/ref/api-languages.texi:
* doc/ref/api-macros.texi:
* doc/ref/api-memory.texi:
* doc/ref/api-modules.texi:
* doc/ref/api-options.texi:
* doc/ref/api-peg.texi:
* doc/ref/api-procedures.texi:
* doc/ref/api-scheduling.texi:
* doc/ref/api-undocumented.texi:
* doc/ref/api-utility.texi:
* doc/ref/expect.texi:
* doc/ref/goops.texi:
* doc/ref/misc-modules.texi:
* doc/ref/posix.texi:
* doc/ref/repl-modules.texi:
* doc/ref/scheme-ideas.texi:
* doc/ref/scheme-scripts.texi:
* doc/ref/srfi-modules.texi:
* gc-benchmarks/larceny/dynamic.sch:
* gc-benchmarks/larceny/twobit-input-long.sch:
* gc-benchmarks/larceny/twobit.sch:
* libguile/gc.h:
* libguile/ioext.c:
* libguile/list.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/threads.c:
* module/ice-9/boot-9.scm:
* module/ice-9/optargs.scm:
* module/ice-9/ports.scm:
* module/ice-9/pretty-print.scm:
* module/ice-9/psyntax.scm:
* module/language/elisp/parser.scm:
* module/language/tree-il/compile-bytecode.scm:
* module/srfi/srfi-37.scm:
* module/srfi/srfi-43.scm:
* module/statprof.scm:
* module/texinfo/reflection.scm:
* test-suite/tests/eval.test:
* test-suite/tests/fluids.test:
Fix typos.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Andy Wingo
3b76a30e3c Tree-IL lowerer has #:dump-optimized-tree-il? option
* module/language/tree-il/optimize.scm (make-optimizer): If the keyword
argument #:dump-optimized-tree-il? is present, print the Tree-IL that
will be handed to the next compiler.  Also re-enable #:verify-tree-il?.
2024-04-23 13:06:34 +02:00
Ludovic Courtès
112b617f59
linker: Create a sparse file only when writing to a file port.
Fixes a regression introduced in
4a0c2433d9: the strategy wouldn’t work
when writing to, say, a bytevector output port.

* module/system/vm/linker.scm (link-elf)[write-padding]: Reintroduce
loop for when PORT is not a file port.  Remove first argument.
2024-04-16 00:34:01 +02:00
Ludovic Courtès
696acfc9e5
‘seek’ now accepts ‘SEEK_DATA’ and ‘SEEK_HOLE’ where supported.
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through.
(scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’.
* module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when
defined.
* test-suite/tests/ports.test ("size of sparse file")
("SEEK_DATA while on data", "SEEK_DATA while in hole")
("SEEK_HOLE while in hole"): New tests.
* NEWS: Update.
2024-04-15 19:58:25 +02:00
Ludovic Courtès
4a0c2433d9
linker: Create sparse files for padding.
Since ‘*lcm-page-size*’ is 64 KiB, this saves disk space for small ‘.go’
files.

* module/system/vm/linker.scm (link-elf)[write-padding]: Rewrite in
terms of ‘seek’.
2024-04-15 19:58:25 +02:00
Denis 'GNUtoo' Carikli
bc2c612b89 SRFI-19: Add support for ISO 8601 zones with a colon.
* module/srfi/srfi-19.scm (zone-reader): handle a colon in the zone.

* test-suite/tests/srfi-19.test (SRFI date/time library test): Add test.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>

[rlb@defaultvalue.org: adjust commit message; add NEWS]
2024-04-13 14:35:29 -05:00
Nikita Domnitskii
025bb024ae eval-string: set port column to column, not line
* module/ice-9/eval-string.scm: set column to column, not line.
2024-04-05 17:51:33 -05:00
Andy Wingo
48548df91e Fix effects analysis: field writes clobber object reads
* module/language/cps/effects-analysis.scm (compute-clobber-map):
Previously a whole-object read would not be clobbered by a specific
field write.  This crops up for the &read introduced at the site of
`cons` for the synthetic car and cdr definitions.  This error was there
before but didn't cause bugs before 3.0.10 because cons got eagerly
lowered to separate allocation and initialization instructions.
2024-03-20 11:50:53 +01:00
Andy Wingo
2c645571b3 Fix inlinable-exports serialization for kwargs
* module/language/tree-il/inlinable-exports.scm (inlinable-exp): Call
assq-ref in the right order.  Embarrassing!
* module/language/tree-il/peval.scm (peval): Print the symbols so that
we can diagnose later failures.
2024-03-18 16:40:32 +01:00
Andy Wingo
e15617dc0e Expose read-c-struct, write-c-struct syntax
* module/system/foreign.scm (read-c-struct): Rename from read-fields.
Export.
(write-c-struct): Rename from write-fields.  Export.
(%write-c-struct, %read-c-struct): Add % prefix to these private
bindings.
2024-03-17 21:40:58 +01:00
Andy Wingo
d7ae468c17 Rework read-fields, write-fields to not return offset
* module/system/foreign.scm (read-fields, write-fields): Don't return
the final offset, as the offset after the final field is not necessarily
the end of the struct, because of padding.
2024-03-17 21:40:58 +01:00
Andy Wingo
7fef214f6e Remove vestigial code from srfi-9
* module/srfi/srfi-9.scm (%define-record-type): No need to define
record-layout.
2024-03-17 21:40:58 +01:00
Andy Wingo
88e0933450 Rework make-c-struct, parse-c-struct
* module/system/foreign.scm (bytevector-complex-single-native-ref)
(bytevector-complex-single-native-set!)
(bytevector-complex-double-native-ref)
(bytevector-complex-double-native-set!): Be more static in our
definitions.
(compile-time-eval):
(switch/compile-time-keys): New helpers.
(align): Make available at compile-time.
(read-field, read-fields, write-field, write-fields): New helpers.  More
efficient than the alist.
(write-c-struct, read-c-struct): Rework in terms of new helpers.
(parse-c-struct): Just use sizeof to get the size.
2024-03-17 21:40:58 +01:00
Andy Wingo
2b58dea2d2 (scheme foreign): API is less configuration-dependent
* libguile/foreign.h:
* libguile/foreign.c: Always define complex-float and complex-double.
Fall back to alignof float / 2*sizeof float if no complex numbers.  (But
with C99 surely it exists everywhere.)
* module/system/foreign.scm (*writers*, *readers*): Always include
complex-float and complex-double readers and writers.
* test-suite/tests/foreign.test: Always run the complex tests.
2024-03-17 21:40:58 +01:00
Andy Wingo
137b0e85b9 (system base target) doesn't load (system foreign)
* module/system/base/target.scm (%native-word-size): Use
most-positive-fixnum instead of importing (system foreign).
2024-03-17 21:40:58 +01:00
Andy Wingo
17e8d7530f peval: Indenting. NFC.
* module/language/tree-il/peval.scm (peval): Reindent.
2024-03-13 20:28:43 +01:00
Andy Wingo
f95bf6921e peval: Enable inlining for functions with kwargs
* module/language/tree-il/peval.scm (peval): Handle all lambda inlining
the same, and extend with support for multiple clauses and keyword
arguments.
* test-suite/tests/peval.test ("case-lambda"): Enable kwarg inlining.
2024-03-13 20:19:59 +01:00
Andy Wingo
c758c99b5e New optimization: demux-lambda
Can help reduce case-lambda* / lambda* at Tree-IL optimization-time.

* module/language/tree-il/demux-lambda.scm: New file.
* am/bootstrap.am (SOURCES): Add new file.
* module/language/tree-il/optimize.scm (make-optimizer):
* module/system/base/optimize.scm (available-optimizations): Enable
demux-lambda at level 2.
2024-03-13 13:11:14 +01:00
Andy Wingo
9e0f03c5fd Macro-introduced top-level vars scope to their module even if unbound
* module/ice-9/psyntax.scm (analyze-variable): Previously, a reference
to a top-level variable in a module other than the current module would
be silently rewritten to reference the current module, if the variable
was unbound in its original module.  This was a hack from the early days
of when we extended psyntax to know about the module system.  Fix to
properly use the scope of the introduced binding instead of the scope of
the macro use site.
* test-suite/tests/syntax.test ("macro-introduced cross-module unbound
identifiers"): Add test.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-02-20 14:15:12 +01:00
Andy Wingo
2717773bb1 Regenerate psyntax-pp.scm
* module/ice-9/psyntax-pp.scm (syntax?): Regenerate.  With the modified
pretty-printer, things are a bit different.
2024-02-20 14:15:12 +01:00
Jonas Hahnfeld
fb1f5e28b1
Match on correct argument in make-custom-port
* module/ice-9/custom-ports.scm (make-custom-port): Match on correct
argument for conversion strategy.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-29 14:44:58 +01:00