1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 15:20:34 +02:00
guile/libguile/private-options.h
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

66 lines
2.1 KiB
C

/* Copyright 2007,2009-2011,2014,2018,2020,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#ifndef PRIVATE_OPTIONS
#define PRIVATE_OPTIONS
/*
debugging.
*/
SCM_INTERNAL scm_t_option scm_debug_opts[];
#define SCM_BACKWARDS_P scm_debug_opts[0].val
#define SCM_BACKTRACE_WIDTH scm_debug_opts[1].val
#define SCM_BACKTRACE_DEPTH scm_debug_opts[2].val
#define SCM_BACKTRACE_P scm_debug_opts[3].val
#define SCM_STACK_LIMIT scm_debug_opts[4].val
#define SCM_SHOW_FILE_NAME scm_debug_opts[5].val
#define SCM_WARN_DEPRECATED scm_debug_opts[6].val
#define SCM_N_DEBUG_OPTIONS 7
/*
printing
*/
SCM_INTERNAL scm_t_option scm_print_opts[];
#define SCM_PRINT_KEYWORD_STYLE_I 0
#define SCM_PRINT_KEYWORD_STYLE (SCM_PACK (scm_print_opts[2].val))
#define SCM_PRINT_ESCAPE_NEWLINES_P scm_print_opts[1].val
#define SCM_PRINT_R7RS_SYMBOLS_P scm_print_opts[2].val
#define SCM_N_PRINT_OPTIONS 3
/*
read
*/
SCM_INTERNAL scm_t_option scm_read_opts[];
#define SCM_RECORD_POSITIONS_P scm_read_opts[0].val
#define SCM_CASE_INSENSITIVE_P scm_read_opts[1].val
#define SCM_KEYWORD_STYLE scm_read_opts[2].val
#define SCM_R6RS_ESCAPES_P scm_read_opts[3].val
#define SCM_SQUARE_BRACKETS_P scm_read_opts[4].val
#define SCM_HUNGRY_EOL_ESCAPES_P scm_read_opts[5].val
#define SCM_CURLY_INFIX_P scm_read_opts[6].val
#define SCM_R7RS_SYMBOLS_P scm_read_opts[7].val
#define SCM_N_READ_OPTIONS 8
#endif /* PRIVATE_OPTIONS */