1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 15:20:34 +02:00
Commit graph

4694 commits

Author SHA1 Message Date
Andy Wingo
91ba12f444 Fix vtable base layout
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Update for unboxed-fields
representation change.
* module/oop/goops.scm (fold-class-slots): Likewise.
2025-06-25 12:55:12 +02:00
Andy Wingo
bd1e5ff688 Switch unboxed-fields bitmask to be a Scheme integer
Requires a full rebuild!!

* libguile/struct.h (SCM_VTABLE_UNBOXED_FIELDS):
(SCM_VTABLE_FIELD_IS_UNBOXED): Use logbit? to determine if a field is
unboxed.
* module/language/cps/guile-vm/lower-primcalls.scm
(vtable-has-unboxed-fields?): Just check against SCM_INUM0.
(vtable-field-boxed?): Likewise, the bitmask is an integer.
* libguile/struct.c (set_vtable_access_fields): Set UNBOXED_FIELDS
bitmask as integer.
2025-06-24 15:05:28 +02:00
Andy Wingo
bc43d4f9a7 Locale have static tc16
* libguile/print.c (iprin1):
* libguile/eq.c (scm_equal_p): Add case for locales and also regexps
which we missed in the past.
* libguile/finalizers.h:
* libguile/finalizers.c (scm_i_add_locale_finalizer):
(run_finalizer): Add locale finalizers.
* libguile/scm.h (scm_tc16_locale): New tc16.
* module/oop/goops.scm:
* libguile/goops.c: Add locale class.
* libguile/i18n.c: Give locale objects their own tc16.
2025-06-18 12:18:24 +02:00
Andy Wingo
3f4048f6c8 Move transcoded ports implementation to Scheme
* libguile/r6rs-ports.c: Remove private transcoded ports implementation.
* module/ice-9/binary-ports.scm: Remove stale comment.
* module/rnrs/io/ports.scm (%make-transcoded-port): New implementation
based on custom ports.
2025-06-18 11:06:12 +02:00
Andy Wingo
66ec19d790 Remove stale comment
* module/ice-9/threads.scm:
2025-06-18 11:04:38 +02:00
Andy Wingo
6ba6fbdf64 Fix GOOPS for <regexp>
* module/oop/goops.scm (<regexp>):
* libguile/goops.c: (scm_class_of): Give regexps their own class; it
doesn't come from smobs.
2025-06-18 10:58:08 +02:00
Andy Wingo
2a015937ca Move bytevector input ports implementation to Scheme
* module/ice-9/binary-ports.scm (open-bytevector-input-port): New
implementation.
* libguile/r6rs-ports.c (scm_open_bytevector_input_port): Proxy to
Scheme.
2025-06-18 10:37:42 +02:00
Andy Wingo
2fc5ff5264 Move bytevector output ports implementation to Scheme
* module/ice-9/binary-ports.scm (bytevector-concatenate-reverse):
(bytevector-copy*): New helpers.
(open-bytevector-output-port): New implementation.
* libguile/r6rs-ports.c (scm_open_bytevector_output_port):
(init_bytevector_port_vars): Arrange to proxy to Scheme.
2025-06-18 10:13:10 +02:00
Andy Wingo
521662d8b7 Move make-regexp, regexp?, regexp-exec to (ice-9 regex)
Also deprecate the C interface.

* libguile/Makefile.am: Don't install regex-posix.h.
* libguile/deprecated.c:
* libguile/deprecated.h: Add deprecated shims for scm_make_regexp et al.
* libguile/init.c: Fix comment.
* libguile/regex-posix.c: Privatize some of the implementation details.
Arrange to install into (ice-9 regex) instead of default environment.
* module/ice-9/deprecated.scm: Add deprecation shims.
* module/ice-9/regex.scm: Add new definitions.
* module/ice-9/sandbox.scm:
* module/scripts/read-scheme-source.scm:
* module/system/repl/server.scm:
* module/texinfo/reflection.scm:
* test-suite/tests/r6rs-exceptions.test:
* test-suite/tests/srfi-10.test: Import (ice-9 regex).
2025-06-17 14:10:12 +02:00
Andy Wingo
ccaff3da39 Allocate a static tc16 for random states
* libguile/random.h (scm_t_rstate): Put a tag word in the beginning.
(scm_is_random_state, scm_to_random_state, scm_from_random_state): New
helpers.
(SCM_RSTATEP, SCM_RSTATE): Use the new helpers.
(scm_masktab): Make private.
* libguile/random.c: Adapt random states to not be a smob.
* libguile/eq.c:
* libguile/print.c:
* libguile/scm.h:
* module/oop/goops.scm: Add new random-state cases.  Fix a number of
classes for other types that were recently changed to not be smobs.
2025-06-17 10:45:27 +02:00
Andy Wingo
63317ff480 Move R5RS promises implementation to Scheme
* am/bootstrap.am (SOURCES):
* module/ice-9/promises.scm: New file.
* libguile/promises.h:
* libguile/promises.c: Delete.
* libguile/deprecated.h:
* libguile/deprecated.c: Add promises shims.
* libguile/init.c:
* libguile/Makefile.am:
* libguile.h: Remove promises mentions.
* module/ice-9/deprecated.scm: Add shims to include promises in the
default environment.
* module/ice-9/null.scm:
* module/ice-9/safe-r5rs.scm:
* module/ice-9/sandbox.scm:
* module/language/bytecode.scm:
* module/language/cps/guile-vm/reify-primitives.scm:
* module/language/elisp/parser.scm:
* module/rnrs/r5rs.scm:
* test-suite/tests/00-initial-env.test:
* test-suite/tests/eval.test:
* test-suite/tests/r4rs.test: Import (ice-9 promises).
2025-06-17 09:41:33 +02:00
Andy Wingo
2f95b31ef5 Fix bug in deprecation wrapper for reset-hook!
* module/ice-9/deprecated.scm (reset-hook!): Fix arity.
2025-06-17 09:39:47 +02:00
Andy Wingo
3cf4ca187c Remove print state objects, and ports-with-print-state
The goal was that, as part of a print operation, all nested prints of
contained data would be able to use the same parameters (e.g. write or
not), and also detect cycles, highlight objects, etc.  The mechanism was
a heap-allocated data structure.  However, given that:

  1. Nobody accessed print states from Scheme

  2. `write` and `display` should move to Scheme anyway, in order to be
     suspendable

  3. The "fancyp" and "highlight" options were unused

  4. A simple stack-allocated data structure with a per-thread key could
     do the trick just as well, without needing the weird freelist
     structure

  5. Ports-with-print-states were a source of bugs

In the end we switch print states to be something completely internal to
print.c.  There are no more SCM print-state objects, and no more
ports-with-print-state.

* libguile/print.h: Remove print state from API.
* libguile/print.c (struct scm_print_state): Move definition here.
(scm_print_opts): Remove "highlight-prefix" and "highlight-suffix"
options, as they were not used.
(ENTER_NESTED_DATA): Remove "fancyp" case.
(init_print_state_key, get_print_state, push_print_state)
(maybe_push_print_state, pop_print_state): New facility to manage stack
of active print states.
(scm_iprin1, print_vector): No more fancyp.
(iprin1): Access "writingp" member directly.  Don't make ports with
print states.
(scm_prin1): Manage print state stack.
(scm_iprlist): No more fancyp.
(scm_valid_oport_value_p): Remove; valid outports are SCM_OPOUTPORTP.
* libguile/backtrace.c:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/goops.c:
* libguile/ioext.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/promises.c:
* libguile/socket.c:
* libguile/struct.c: Remove cases that dealt with
ports-with-print-states.
* libguile/private-options.h: Remove highlight options.
* module/ice-9/ports.scm (inherit-print-state): Deprecate.
* libguile/deprecated.c:
* libguile/deprecated.h: Add deprecation shims for print states, as far
as that is possible.
2025-06-17 09:38:46 +02:00
Andy Wingo
f930af2737 Move implementation of hooks to Scheme module
* module/ice-9/hooks.scm: New file.
* am/bootstrap.am: Add new file.
* module/ice-9/deprecated.scm: Add trampolines to (ice-9 hooks).
* module/ice-9/scm-style-repl.scm:
* module/ice-9/session.scm:
* module/ice-9/top-repl.scm:
* module/scripts/scan-api.scm:
* guile-readline/ice-9/readline.scm:
* benchmark-suite/benchmark-suite/lib.scm:
* module/system/repl/command.scm:
* module/system/repl/common.scm:
* module/system/repl/debug.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/hooks.scm:
* module/system/repl/reader.scm:
* module/system/repl/repl.scm:
* module/ice-9/history.scm:
* test-suite/tests/hooks.test: Use the new module.
* module/oop/goops.scm: Remove <hook> class definition.
* libguile/vm.c:
* libguile/init.c:
* libguile/Makefile.am:
* libguile.h: Remove hooks.h includes.
* libguile/hooks.c:
* libguile/hooks.h: Remove.
* libguile/deprecated.h:
* libguile/deprecated.c: Add deprecation shims for C API.
2025-06-16 13:11:28 +02:00
Andy Wingo
110eafcafe Deprecate module-defined-hook
Instead there is a module-definition-observer parameter.

* module/ice-9/boot-9.scm (module-definition-observer): New param.
* module/ice-9/deprecated.scm (module-defined-hook): Add deprecated
definition; install as definition observer.
2025-06-16 11:59:52 +02:00
Andy Wingo
6190b5a02f Fix api-diff.scm typo
* module/scripts/api-diff.scm (get): Fix typo introduced by my
refactoring.
2025-06-16 11:45:52 +02:00
Andy Wingo
4b96e2509e Move REPL-related hooks to their own module
* guile-readline/ice-9/readline.scm: Import hooks and reader modules.
(activate-readline): Install via set-repl-reader!.
* module/ice-9/boot-9.scm (abort-hook, before-backtrace-hook)
(after-backtrace-hook): Move to (ice-9 scm-style-repl).
(before-error-hook, after-error-hook, before-read-hook)
(after-read-hook, before-eval-hook, after-eval-hook)
(before-print-hook, after-print-hook, exit-hook): Move to (system repl
hooks).
(repl-reader): Move to (system repl reader).
* module/system/repl/hooks.scm:
* module/system/repl/reader.scm: New files.
* am/bootstrap.am (SOURCES): Add the new files.
* module/system/repl/repl.scm:
* module/system/repl/server.scm:
* module/system/vm/inspect.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/debug.scm:
* module/system/repl/common.scm:
* module/system/repl/command.scm:
* module/ice-9/top-repl.scm:
* module/ice-9/scm-style-repl.scm:
* module/ice-9/history.scm:
* module/ice-9/deprecated.scm: Adapt to import new modules.
2025-06-16 11:45:42 +02:00
Andy Wingo
04fdc33a54 Replace after-gc-hook with {add,remove}-after-gc-callback!
* libguile/gc.c:
(scm_gc_event_listener_restarting_mutators):
(after_gc_async_thunk):
(scm_init_gc): Instead of using a hook for after-gc callbacks, just use
a list of thunks.  Will allow us to move hooks to Scheme.
(add-after-gc-callback!, remove-after-gc-callback!): New functions.
* libguile/gc.h (scm_after_gc_hook): Remove.
* libguile/scmsigs.c (signal_delivery_thread): Update comment.
* module/statprof.scm (gcprof):
* test-suite/tests/gc.test ("gc"): Update to use new functions.
2025-06-16 11:36:07 +02:00
Andy Wingo
f436e550ea Pipes use finalizers instead of guardians
* module/ice-9/popen.scm (reap-pipe, open-pipe*): Instead of pumping a
guardian in the after-gc-hook, attach a finalizer.  This will pump pipes
in a thread instead of needing to do it ourselves.
2025-06-16 11:36:07 +02:00
Andy Wingo
2c186f835b Allocate a static tc16 to directory streams
* libguile/filesys.c: Use a static tc16.
* libguile/eq.c:
* libguile/filesys.h:
* libguile/finalizers.c:
* libguile/finalizers.h:
* libguile/goops.c:
* libguile/print.c:
* libguile/scm.h:
* module/oop/goops.scm: Adapt for the new tc16.
2025-06-13 16:39:39 +02:00
Andy Wingo
12da6739b1 Give continuations (contregs) their own static tc16
* libguile/continuations-internal.h: New file, for internal definitions.
* libguile/continuations.h: Move out internal definitions.
* libguile/Makefile.am: Add new file.
* libguile/continuations.c: Adapt to put the tag in the beginning of the
continuation (contregs) structure.
* libguile/eq.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/print.c:
* libguile/scm.h:
* libguile/stacks.c:
* libguile/vm.c:
* module/oop/goops.scm: Adapt to contregs tc16 change.
2025-06-13 13:13:02 +02:00
Andy Wingo
f47fe6e752 Convert mutexes, condition vars to statically-allocated tc16
* libguile/scm.h: Add statically allocated tc16s for condvars and
mutexes.
* libguile/threads.c: Adapt to declare tag inline to struct scm_cond and
struct scm_mutex.
* libguile/threads.h: Expose printing procedures internally.
* module/oop/goops.scm:
* libguile/goops.c: Fix to statically allocate condition variable and
mutex classes.
* libguile/eq.c:
* libguile/print.c: Adapt.
2025-06-13 11:48:19 +02:00
Andy Wingo
7a1406891f Move char-set-cursor implementation to Scheme
Also deprecate the C interface.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_char_set_cursor):
(scm_char_set_ref):
(scm_char_set_cursor_next):
(scm_end_of_char_set_p): Deprecate.
* libguile/srfi-14.c (charset-mutable?, char-set-ranges)
(charset-set-ranges!): New accessors, exposed internally to srfi-14.scm.
* libguile/srfi-14.c (scm_boot_srfi_14): Remove scm_tc16_charset_cursor.
* module/srfi/srfi-14.scm (<char-set-cursor>): Implement as a record.
2025-06-13 11:13:54 +02:00
Andy Wingo
4516119dd1 Deprecate srfi-14 in default environment
* libguile/srfi-14.c:
* module/srfi/srfi-14.scm: Arrange to define bindings here instead of in
the default environment.
* libguile/init.c:
* libguile/srfi-14.h: Fix so that srfi-14 can register an extension to
be loaded later.
* libguile/unidata_to_charset.awk: Rename private cs_letter_plus_digit
to cs_letter_and_digit.
* module/ice-9/deprecated.scm: Add deprecation trampolines for srfi-14.
* module/ice-9/sandbox.scm:
* module/language/elisp/lexer.scm:
* module/language/scheme/decompile-tree-il.scm:
* module/rnrs/unicode.scm:
* module/sxml/simple.scm:
* module/system/base/syntax.scm:
* module/system/repl/server.scm:
* module/texinfo/serialize.scm:
* module/texinfo/string-utils.scm:
* module/web/http.scm:
* module/web/uri.scm:
* test-suite/tests/strings.test:
* test-suite/tests/tree-il.test: Adapt for srfi-14 being in a module.
2025-06-13 09:03:20 +02:00
Andy Wingo
7d899fa7c7 Refactor (ice-9 deprecated) to be more concise
* module/ice-9/deprecated.scm (define-deprecated-trampoline):
(define-deprecated-trampolines): New helpers.  Use them to define all
the trampolines.
2025-06-12 21:54:07 +02:00
Andy Wingo
c794c086d5 Change charsets to use bytevector to store char ranges
This doesn't fundamentally change how charsets are represented, but it
will eventually allow us to migrate more functionality to scheme, as the
charsets have a Scheme-legible representation.  Also, and this is really
the point, give charsets their own type code, so that they can be
traced precisely.

* libguile/eq.c:
* libguile/evalext.c:
* libguile/goops.c:
* libguile/print.c:
* module/oop/goops.scm: Adjust to new tc16.
* libguile/srfi-14.h: Make private things private.
* libguile/srfi-14.c: Change to use bytevectors for the ranges.  No
functional change.
2025-06-12 16:49:27 +02:00
Andy Wingo
d6e59a1d3e Convert bitvectors to use inline-only word-size units
* libguile/bitvectors.h: Unit of bitvectors is scm_t_bits, not uint32_t.
* libguile/bitvectors.c: Adapt implementation.
(make_bitvector): Malloc pointerless instead, with inline bits.
* libguile/posix.c (scm_setaffinity):
* libguile/bytevectors.c (uniform-array->bytevector): Adapt to unit size
change.
* module/system/vm/assembler.scm (intern-constant, link-data): Adapt to
bitvector representation change.
2025-06-03 16:54:19 +02:00
Andy Wingo
9ff7c0651c Give arrays a proper type in C land
As long as we have a tc7 for arrays, we should be able to access it with
a struct type instead of casting each word.

* libguile/arrays-internal.h: New file.
* libguile/arrays.h (scm_array_p): Take just one argument.
(SCM_I_ARRAYP):
(SCM_I_ARRAY_NDIM):
(SCM_I_ARRAY_V):
(SCM_I_ARRAY_BASE):
(SCM_I_ARRAY_DIMS):
(SCM_I_ARRAY_SET_V):
(SCM_I_ARRAY_SET_BASE): Remove.
(scm_i_raw_array, scm_i_make_array, scm_i_shap2ra, scm_init_arrays):
Remove internally-linked decls.
* libguile/init.c:
* libguile/print.c:
* libguile/array-handle.c: Use interfaces from new file.
* module/system/vm/assembler.scm: Update, as we now shift the dimension
count by only 16.  Requires a rebuild!
2025-06-03 14:55:09 +02:00
Andy Wingo
12e8772403 Move array-map / array-cell functions to Scheme module
* libguile/array-map.c:
* libguile/array-map.h: Remove.

* module/ice-9/deprecated.scm:
* libguile/deprecated.h:
* libguile/deprecated.c: Add deprecation shims.

* module/ice-9/arrays.scm: Move all array-map functionality here.

* libguile/Makefile.am:
* libguile/init.c:
* libguile.h: Remove array-map.h use.

* libguile/arrays.c (scm_i_array_equal_p, scm_i_array_copy): New
helpers.
(scm_array_cell_ref, scm_array_cell_set_x): Move to Scheme.
* libguile/arrays.h:
* libguile/eq.c (scm_equal_p):
* libguile/sort.c (scm_sort): Use new arrays.c helpers.
* module/ice-9/pretty-print.scm:
* module/oop/goops/save.scm: Import (ice-9 arrays).
2025-06-03 14:34:26 +02:00
Andy Wingo
51bc69dd1c Fix bytevector mutators to correctly check for mutability
Previously, bytevectors that were serialized into binaries were actually
mutable by compiled bytevector-u8-set! et al.

* libguile/bytevectors.h (SCM_F_BYTEVECTOR_IMMUTABLE): Renumber to 0x80,
as for immutable vectors.
(SCM_BYTEVECTOR_CONTIGUOUS_P): Just use SCM_CELL_TYPE.
(SCM_BYTEVECTOR_FLAGS): Remove unused accessor.
* module/language/tree-il/compile-cps.scm (bytevector-set-converter):
Emit mutable-bytevector? instead of bytevector?.
* module/system/vm/assembler.scm (link-data): Update immutable flag.
* module/language/cps/compile-bytecode.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/system/base/types/internal.scm: Update for immutable-bytevector
predicates.
2025-05-30 16:48:26 +02:00
Andy Wingo
043a5b62bb Rework treatment of bytevector flags
Before, they were always shifted by 7.  Now the flags are just above
0x7f and just the element type is shifted, but by 16.

* libguile/bytevectors.h (SCM_BYTEVECTOR_FLAGS): Rework to not shift.
(SCM_SET_BYTEVECTOR_FLAGS): Remove.
(SCM_MUTABLE_BYTEVECTOR_P): Don't shift the immutable flag.
(SCM_BYTEVECTOR_ELEMENT_TYPE): Shift right by 16.
* libguile/bytevectors.c (SCM_BYTEVECTOR_SET_FLAG): Remove unused
helper.
(make_bytevector_tag): New helper.
(make_bytevector): Use new helper.
(make_bytevector_from_buffer): Add flags and parent args, and use new
helper.
(scm_c_take_gc_bytevector):
(scm_c_take_typed_bytevector):
(scm_bytevector_slice): Update callers.
* module/system/vm/assembler.scm (link-data): Don't shift the flag by 7;
instead shift the element type by 16.
2025-05-30 14:19:30 +02:00
Andy Wingo
b96a22d3ea primitive-load after boot uses read-syntax
* module/ice-9/boot-9.scm (primitive-load): Define a version in Scheme
that uses read-syntax.  This allows the expander to be able to access
source locations.
2025-05-15 22:36:41 +02:00
Mikael Djurfeldt
f948d414f8 Fixed documentation for make-guardian.
* module/ice-9/guardians.scm (make-guardian): Copy full documentation of
old C version.
2025-05-14 22:00:06 +02:00
Andy Wingo
1e06be2fa8 Remove weak sets
* libguile/weak-set.c:
* libguile/weak-set.h: Remove.
* libguile.h:
* libguile/Makefile.am: Adapt build and includes.
* libguile/scm.h: Remove weak set tc7.
* libguile/evalext.c:
* libguile/hash.c:
* libguile/ioext.c:
* libguile/ports.c:
* libguile/print.c: Remove weak-set includes and tc7 cases.
* libguile/init.c: No need to init weak sets.
* module/language/cps/compile-bytecode.scm:
* module/system/base/types.scm:
* module/system/base/types/internal.scm:
* module/system/vm/assembler.scm: Adapt to tc7 change.
2025-05-14 16:12:11 +02:00
Mikael Djurfeldt
2a6f6ec354 Add documentation for make-guardian.
* module/ice-9/guardians.scm (make-guardian): Add documentation from old
C version.
2025-05-14 09:59:04 +02:00
Andy Wingo
8280c8485f Move weak table implementation to Scheme
* libguile/weak-table.c:
* libguile/weak-table.h: Remove.

* libguile.h: Remove weak-table.h include.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(DOT_X_FILES):
(DOT_DOC_FILES):
(modinclude_HEADERS): Remove weak-table.[ch].

* libguile/evalext.c:
* libguile/fluids.c:
* libguile/hash.c:
* libguile/init.c:
* libguile/print.c:
* libguile/scm.h: Remove uses of weak-table.h and free up the tc7.

* libguile/hashtab.c:
* libguile/hashtab.h: Add deprecated shims to dispatch to (ice-9
weak-tables) when working on weak tables.

* module/ice-9/weak-tables.scm: New implementation.  Embeds the hash and
equality functions in the table itself.

* module/ice-9/object-properties.scm:
* module/ice-9/poe.scm:
* module/ice-9/popen.scm:
* module/ice-9/source-properties.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/ecmascript/array.scm:
* module/language/ecmascript/function.scm:
* module/oop/goops/save.scm:
* module/srfi/srfi-18.scm:
* module/srfi/srfi-69.scm:
* module/system/base/types.scm:
* module/system/base/types/internal.scm:
* module/system/foreign.scm:
* module/system/vm/assembler.scm:
* test-suite/tests/gc.test:
* test-suite/tests/hash.test:
* test-suite/tests/srfi-69.test:
* test-suite/tests/types.test:
* test-suite/tests/weaks.test: Update to use new, non-deprecated weak
tables API.
2025-05-13 14:57:31 +02:00
Andy Wingo
d457aaa57d Add ephemeron-table-clear!; ephemeron key can be immediate
* libguile/ephemerons.c (scm_make_ephemeron): Relax restriction that key
be a heap object.  It's too annoying otherwise.
(scm_c_ephemeron_table_clear_x):
(scm_ephemeron_table_clear_x): New interface.
* module/ice-9/ephemerons.scm: Expose ephemeron-table-clear!.
* test-suite/tests/ephemerons.test ("ephemerons"): Update tests.
2025-05-13 14:55:38 +02:00
Andy Wingo
c35cbd65f1 Remove (ice-9 hcons)
It was never documented, never used, and uses the gross assoc interface
to doubly-weak tables.  Good-bye!

* module/ice-9/hcons.scm: Remove.
* am/bootstrap.am: Remove hcons from build.
* module/ice-9/poe.scm: Extract the one procedure from hcons that poe
uses, which notably doesn't have anything to do with hcons.
2025-05-13 12:20:22 +02:00
Andy Wingo
e3b743dc72 Move source properties out to a module
* module/ice-9/source-properties.scm: New file, providing the
source-properties API, as well as a replacement for `read' that always
attaches source properties, regardless of the 'positions option on the
port.

* am/bootstrap.am (SOURCES): Add the new file.

* libguile/srcprop.c:
* libguile/srcprop.h: Remove.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(DOT_X_FILES):
(DOT_DOC_FILES):
(modinclude_HEADERS):
* libguile.h: Remove srcprop.h.

* libguile/deprecated.c:
* libguile/deprecated.h: Add deprecation shims for srcprop.h interface.

* libguile/backtrace.c:
* libguile/debug.c:
* libguile/eval.c:
* libguile/init.c:
* libguile/memoize.c:
* libguile/promises.c:
* libguile/read.c:
* libguile/syntax.c: Remove needless srcprop.h includes.

* module/ice-9/boot-9.scm: Reorder some definitions so that deprecated
modules can use the (system syntax internal) module.

* module/ice-9/deprecated.scm: Add shims for Scheme source-properties
interface.

* module/ice-9/read.scm (read): Never attach source properties.  Users
that want source can use read-syntax.

* module/language/cps.scm:
* module/language/cps/spec.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/tree-il.scm:
* module/language/tree-il/spec.scm:
* module/language/wisp.scm:
* module/system/base/lalr.scm:
* test-suite/tests/elisp-reader.test:
* test-suite/tests/reader.test:
* test-suite/tests/srcprop.test:
* test-suite/tests/srfi-105.test:
* test-suite/tests/srfi-119.test: Use the (ice-9 source-properties)
module to get access to source properties.
2025-05-12 16:29:04 +02:00
Andy Wingo
b6b6f62548 syntax-source returns a vector
* libguile/syntax.c (HAS_SOURCE_WORD_FLAG): Remove; all syntax objects
now have a source word.
(sourcev_to_props, props_to_sourcev): Remove.
(scm_make_syntax): Require source to be a vector or #f.
(scm_syntax_source): Just return source object.
(scm_syntax_sourcev): Remove.
* libguile/syntax.h: Remove scm_syntax_sourcev.
* module/srfi/srfi-64.scm (syntax->source-properties):
* module/system/base/types.scm (cell->object):
* module/ice-9/boot-9.scm (case, current-source-location, current-filename)
(define-module, load): Adapt for syntax-source returning a vector.
* module/ice-9/psyntax-pp.scm: Regen.
* module/ice-9/psyntax.scm: Rename uses of syntax-sourcev to
syntax-source.
* module/system/syntax.scm (syntax-sourcev): Add deprecated shim.
(print-syntax): Use sourcev.
* module/system/vm/assembler.scm (intern-constant):
(link-data): Always write source word.
* test-suite/tests/reader.test ("read-syntax"): Update expectation.
2025-05-12 15:05:40 +02:00
Andy Wingo
9ab8f3d807 tree-il-src is a vector, replaces tree-il-srcv
* module/language/tree-il.scm (tree-il-src): Always a vector now;
tree-il-srcv is gone.  An incompatible change but we are in the
compiler.
(location): For parse-tree-il, make vector locations instead of alists.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-bytecode.scm:
* module/language/tree-il/compile-cps.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/letrectify.scm:
* module/language/tree-il/peval.scm:
* module/system/vm/assembler.scm: Update all uses to expect vectors
instead of alists and to use tree-il-src instead of tree-il-srcv.
* module/language/elisp/compile-tree-il.scm (location): Create vectors,
not alists.
* test-suite/tests/compiler.test ("psyntax"): Update syntax-source
expectation.
2025-05-12 13:45:21 +02:00
Andy Wingo
f399f36d37 Remove use of source properties in psyntax
* module/ice-9/psyntax.scm (source-annotation): Only get source info
from syntax objects.
(strip): Don't attach source info.
(macroexpand): Don't proxy source info in that isn't in a syntax object.
(datum->syntax): Don't proxy source info from source-properties.
* test-suite/tests/compiler.test ("psyntax"):
* test-suite/tests/coverage.test (code):
* test-suite/tests/eval-string.test ("basic"):
* test-suite/tests/syntax.test ("expressions"):
* test-suite/tests/tree-il.test ("warnings"): Update tests that attach
source properties to use read-and-compile, or read-syntax.
2025-05-12 13:45:21 +02:00
Andy Wingo
05dd829ad3 boot-9: case warnings use syntax-source
* module/ice-9/boot-9.scm (case): Use syntax-source instead of
source-properties.
2025-05-12 13:45:21 +02:00
Andy Wingo
be6a5c6c75 Deprecate object-properties in the main environment
They should be deprecated entirely except that they are used for object
documentation.  Some other day.

* libguile/objprop.c:
* libguile/objprop.h: Remove.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_object_properties):
(scm_set_object_properties_x):
(scm_object_property):
(scm_set_object_property_x): Add deprecation shims.
* module/ice-9/deprecated.scm (object-properties*):
(set-object-properties!*):
(object-property*):
(set-object-property!*): Add deprecation shims.
* libguile/init.c:
* libguile.h: Remove objprops.
* module/ice-9/object-properties.scm: Add pure Scheme implementation
here.
* module/ice-9/documentation.scm:
* module/scripts/api-diff.scm:
* module/scripts/read-text-outline.scm:
* module/scripts/scan-api.scm:
* module/scripts/summarize-guile-TODO.scm:
* module/srfi/srfi-64.scm: Include object-properties module.
2025-05-12 13:45:21 +02:00
Andy Wingo
134c3be452 Add ephemeron tables
* libguile/ephemerons.h:
* libguile/ephemerons.c (scm_c_make_ephemeron):
(scm_c_ephemeron_key):
(scm_c_ephemeron_value):
(scm_c_ephemeron_mark_dead_x):
(scm_c_ephemeron_swap_x):
(scm_c_ephemeron_next): Add C ephemeron API.
(scm_make_ephemeron, scm_ephemeron_key, scm_ephemeron_value)
(scm_ephemeron_mark_dead_x): Dispatch to helpers above.
(scm_ephemeron_swap_x, scm_ephemeron_mark_dead_x): New Scheme-exposed
functions.
(scm_c_make_ephemeron_table):
(scm_c_ephemeron_table_length):
(scm_c_ephemeron_table_ref):
(scm_c_ephemeron_table_push_x):
(scm_c_ephemeron_table_try_push_x): New C API for tables of ephemerons.
(scm_ephemeron_table_length):
(scm_ephemeron_table_ref):
(scm_ephemeron_table_push_x):
(scm_ephemeron_table_try_push_x): New Scheme-exposed API.
(scm_c_ephemeron_hash_table_refq):
(scm_c_ephemeron_hash_table_setq_x):
(scm_c_ephemeron_hash_table_copy): New C API for use by internal weak
table users (dynamic states, etc).

* module/ice-9/ephemerons.scm: Add new Scheme API.

* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (scm_class_of, %goops-early-init):
* libguile/print.c (iprin1):
* module/oop/goops.scm:
* libguile/scm.h (scm_tc7_ephemeron_table): Add new tc7 for ephemeron
tables.

* test-suite/tests/ephemerons.test ("ephemeron tables"): Add tests.
2025-05-12 13:45:21 +02:00
Andy Wingo
67dca3a1f5 Move weak tables out to a module
* module/ice-9/weak-tables.scm: New file.

* am/bootstrap.am (SOURCES): Wire it up.
* module/ice-9/deprecated.scm: Add deprecation shims.
* libguile/init.c (scm_i_init_guile): Don't add weak bindings to default
module.
* libguile/weak-table.h:
* libguile/weak-table.c (scm_init_weak_tables):
(scm_weak_table_prehistory): Arrange to load bindings from the weaks
module.
* module/ice-9/hcons.scm:
* module/ice-9/object-properties.scm:
* module/ice-9/poe.scm:
* module/ice-9/popen.scm:
* module/ice-9/sandbox.scm:
* module/language/ecmascript/function.scm:
* module/oop/goops/save.scm:
* module/srfi/srfi-18.scm:
* module/srfi/srfi-69.scm:
* module/system/foreign.scm:
* test-suite/tests/gc.test:
* test-suite/tests/hash.test:
* test-suite/tests/types.test:
* test-suite/tests/weaks.test: Adapt to use the new module.
2025-05-12 13:45:07 +02:00
Andy Wingo
3a9c0939a0 Move make-object-property out to a module
This will allow for weak tables to be implemented partly in Scheme.

* module/ice-9/object-properties.scm: New file.

* am/bootstrap.am (SOURCES): Add new file.

* module/ice-9/boot-9.scm:
* module/ice-9/deprecated.scm (make-object-property*): Deprecate
make-object-property in default env and add a shim.

* module/ice-9/buffered-input.scm (ice-9):
* module/language/elisp/boot.el (plist-function):
* module/scripts/frisk.scm (scripts):
* module/web/http.scm (web): Adapt users to import the new module.
2025-05-12 13:45:07 +02:00
Andy Wingo
1f96d1bf4b Move to store thread join cond/lock/results directly
* libguile/threads.h: Add join data directly on the thread instead of
using a Scheme-side weak table.  It's less complicated and it will let
the weak table implementation use locks in Scheme; otherwise you would
have threads depending on weak tables and vice versa.
* libguile/threads.c (scm_trace_thread, guilify_self_1): Init and mark
the new members.
(thread_join_cond, thread_join_lock, thread_join_results)
(thread_init_joinable_x, thread_set_join_results_x): New accessors.
* module/ice-9/threads.scm (call-with-new-thread, join-thread): Use the
new accessors.
2025-05-12 13:45:07 +02:00
Andy Wingo
852c0b05c7 Remove module weak observers
If that's what you want, you need to bring your own weak hash table on a
normal observer.

* module/ice-9/boot-9.scm (module): Remove weak-observers field.
(make-module, make-autoload-interface): Don't pass weak table to
constructor.
(module-observe-weak): Remove.
(module-unobserve, module-call-observers): Remove weak case.
* module/ice-9/deprecated.scm (module-observe-weak): Dispatch to
module-observe.
* test-suite/tests/modules.test ("observers"): Adapt.
2025-05-12 13:45:07 +02:00
Andy Wingo
c63f9101f8 Reimplement weak vectors in Scheme using ephemerons
* module/ice-9/weak-vector.scm: New implementation, same interface.

* doc/ref/api-memory.texi (Weak vectors): Default weak vector value was
documented as empty list when it was actually unspecified, but #f is
most useful, so we change documentation and code to match.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(DOT_X_FILES):
(DOT_DOC_FILES):
(noinst_HEADERS):
(modinclude_HEADERS):
* libguile.h:
* libguile/deprecated.c:
* libguile/deprecated.h:
* libguile/init.c:
* libguile/weak-vector.c:
* libguile/weak-vector.h: Remove C weak vector implementation, replaced
with deprecation stubs that call out to Scheme.

* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-list.h: Remove unused internal header.

* libguile/eq.c:
* libguile/evalext.c:
* libguile/goops.c:
* libguile/hash.c:
* libguile/scm.h:
* module/system/base/types.scm:
* module/system/base/types/internal.scm:
* module/system/vm/assembler.scm: Remove wvect tc7.
2025-05-05 16:29:24 +02:00