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

1048 commits

Author SHA1 Message Date
Ludovic Courtès
de5cf50aba i18n: 'number->locale-string' guesses the minimum number of decimals.
This feature was removed by 4aead68cdb.

* module/ice-9/i18n.scm (number-decimal-string): Rewrite the case where
DIGIT-COUNT is not an integer.
(number->locale-string): Always pass FRACTION-DIGITS to
'number-decimal-string'.
* test-suite/tests/format.test ("~h localized number")["1234.5"]
["padding", "padchar"]: Remove decimal specifier.
* test-suite/tests/i18n.test ("number->locale-string")
["fraction",
* test-suite/tests/i18n.test ("format ~h")["12 345,678"]: Remove decimal
specifier.  Remove one decimal.
* doc/ref/api-i18n.texi (Number Input and Output): Update
'number->locale-string' doc to mention the number of decimals.
2017-03-01 21:16:49 +01:00
Ludovic Courtès
4c7d1a64fa i18n: Fix corner cases for monetary and number string conversions.
Fixes <http://bugs.gnu.org/24990>.
Reported by Martin Michel <dev@famic.de>.

* module/ice-9/i18n.scm (integer->string, number-decimal-string): New
procedures.
(monetary-amount->locale-string): Use them instead of 'number->string'
followed by 'string-split'.
(number->locale-string): Likewise.
* test-suite/tests/i18n.test ("number->locale-string")["fraction"]: Add
second argument to 'number->locale-string'.
["fraction, 1 digit"]: Round up.
["fraction, 10 digits", "trailing zeros", "negative integer"]: New
tests.
* test-suite/tests/i18n.test ("format ~h"): Pass the number of decimals
for ~h.
("monetary-amount->locale-string")["French"]: Always expect two decimals
after the comma.
["one cent", "very little money"]: New tests.
* test-suite/tests/format.test ("~h localized number")["1234.5"]:
Specify the number of decimals explicitly.
["padding"]: Expect zero decimals.
["padchar"]: Ask for one decimal.
["decimals", "locale"]: Adjust rounding.
2017-03-01 21:16:25 +01:00
Ludovic Courtès
19d274c680 i18n: Do not represent zero as "-0".
Partly fixes <http://bugs.gnu.org/24990>.
Reported by Martin Michel <dev@famic.de>.

* module/ice-9/i18n.scm (monetary-amount->locale-string): Don't negate
AMOUNT when it's zero.
(number->locale-string): Likewise.
* test-suite/tests/i18n.test ("number->locale-string")["positive inexact
zero, 1 digit"]: New test.
("monetary-amount->locale-string")["positive inexact zero"]: New test.
2017-03-01 21:04:42 +01:00
Ludovic Courtès
4d3a14924f scandir: Avoid 'stat' calls on each entry.
* module/ice-9/ftw.scm (scandir): Rewrite in terms of 'readdir'.
2017-03-01 20:40:26 +01:00
Wilfred Hughes
67b8b6fb06 Favor docstrings for describing the purpose of functions.
* module/ice-9/boot-9.scm: Where functions have docstring-style
  comments, make them proper docstrings.
2017-03-01 10:09:38 +01:00
Andy Wingo
68f13adaaf Better errors for odd-length keyword args
* libguile/vm-engine.c (bind-kwargs):
* libguile/vm.c (vm_error_kwargs_missing_value):
* libguile/eval.c (error_missing_value)
  (prepare_boot_closure_env_for_apply): Adapt to mirror VM behavior.
* libguile/keywords.c (scm_c_bind_keyword_arguments): Likewise.
* module/ice-9/eval.scm (primitive-eval): Update to error on (foo #:kw)
  with a "Keyword argument has no value" instead of the horrible "odd
  argument list length".  Also adapts to the expected args format for
  the keyword-argument-error exception printer in all cases.  Matches
  1.8 optargs behavior also.
* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (test_missing_value):
  (missing_value_error_handler): Update test.
* test-suite/tests/optargs.test: Add tests.
2017-02-28 22:01:20 +01:00
Andy Wingo
631e9901d8 Declare module exports before loading imports
* module/ice-9/boot-9.scm (define-module*): Process module imports after
  module exports.  Allows for an additional kind of circular module
  imports (see https://bugs.gnu.org/15540).
* test-suite/tests/modules.test ("circular imports"): Add test.
2017-02-28 11:49:15 +01:00
Andy Wingo
9e28a12121 Revert "futures: Limit the number of nested futures on the same stack."
This reverts commit 8a177d316c, though
keeping the additional tests.  (Guile 2.2 doesn't have a fixed stack
limit).
2017-02-28 10:45:21 +01:00
Andy Wingo
6e0965104c Add accept4 support
* doc/ref/posix.texi (Network Sockets and Communication): Add
  documentation.
* libguile/socket.c (scm_accept4): New function, replaces accept
  implementation.
  (scm_accept): Call scm_accept4.
  (scm_init_socket): Define SOCK_CLOEXEC and SOCK_NONBLOCK.
* libguile/socket.h: Add private scm_accept4 decl.
* module/ice-9/suspendable-ports.scm (accept): Update.
2017-02-15 22:10:25 +01:00
Andy Wingo
8a4774dec8 Prevent TOCTTOU bugs in suspendable ports
* module/ice-9/suspendable-ports.scm: Prevent TOCTTOU bugs by
  additionally returning the buffer and offset when we compute an
  amount-buffered.
2017-02-08 15:09:14 +01:00
Daniel Llorens
93cbaef134 Fix rank 0 arrays and nested arrays in truncated-print
* module/ice-9/pretty-print.scm (print): In the array case, pass
  #:inner? along to (print-sequence), unless we're at the last dimension
  of the array.
  Special case for 0-rank arrays, which cannot be empty and have no
  length.
* test-suite/tests/print.test: Test some of the cases fixed by this
  patch.
2017-02-07 15:56:40 +01:00
Daniel Llorens
ee2125c639 Support arrays in truncated-print
* module/ice-9/pretty-print.scm (print): Handle general arrays.
* test-suite/tests/print.test: Test truncated-print with general arrays.
2017-02-07 12:19:04 +01:00
Andy Wingo
498f3f9568 Avoid stacks in dynamically-bound values
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_find_old_fluid_value): New
  function.
* libguile/fluids.c (saved_dynamic_state_ref): New helper.
  (scm_fluid_ref): Fix docstring.
  (scm_fluid_ref_star): New function allowing access to previous values
  for a fluid.
  (scm_dynamic_state_ref): New internal function.
* libguile/fluids.h: Add scm_fluid_ref_star and scm_dynamic_state_ref.
* libguile/stacks.c (scm_stack_id): Adapt to %stacks not being a chain.
* libguile/throw.c (catch, throw_without_pre_unwind): Adapt to
  %exception-handlers not being a chain.
* module/ice-9/boot-9.scm (catch, dispatch-exception): Instead of having
  %exception-handlers be a chain, use fluid-ref* to access the chain
  that is in place at the time the exception is thrown.  Prevents
  unintended undelimited capture of the current exception handler stack
  by a delimited "catch".
  (%start-stack): Similarly, don't be a chain.
* module/system/repl/debug.scm (frame->stack-vector):
* module/system/repl/error-handling.scm (call-with-error-handling):
* module/ice-9/save-stack.scm (save-stack): Adapt to %stacks not being a
  chain.
* test-suite/tests/exceptions.test ("delimited exception handlers"): Add
  tests.
* doc/ref/api-control.texi (Fluids and Dynamic States): Add docs.
2017-02-07 09:57:55 +01:00
Andy Wingo
a000e5c38d Enable interrupts only when running thread body
* libguile/threads.c (really_launch): Start threads with asyncs
  blocked.
* module/ice-9/threads.scm (call-with-new-thread): Unblock asyncs once
  we have the bookkeeping sorted out.  Don't use
  with-continuation-barrier; it's not needed.  Print nice thread
  backtraces.
2017-01-08 13:02:56 +01:00
Andy Wingo
6dd87f4d8c Add suspendable-continuation?
* doc/ref/api-control.texi (Prompt Primitives): Document
  suspendable-continuation?.
* libguile/control.c (scm_suspendable_continuation_p): New procedure.
  (scm_init_ice_9_control): New extension procedure, defines
  suspendable-continuation?.
  (scm_init_control): Register scm_init_ice_9_control.
* libguile/eval.c (eval):
* libguile/throw.c (catch):
* libguile/continuations.c (scm_i_make_continuation): Restore resumable
  prompt cookie after continuation invocation.
* libguile/vm.c (scm_call_n): Arrange to set resumable_prompt_cookie
  during invocation of VM.
* libguile/vm.h (struct scm_vm): Add resumable_prompt_cookie member.
* module/ice-9/control.scm: Export suspendable-continuation?.
* test-suite/tests/control.test ("suspendable-continuation?"): New
  test.
2016-12-12 21:13:00 +01:00
Andy Wingo
7184c176b4 with-dynamic-state compiler and VM support
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_DYNAMIC_STATE):
* libguile/dynstack.c (DYNAMIC_STATE_WORDS, DYNAMIC_STATE_STATE_BOX):
  (scm_dynstack_push_dynamic_state):
  (scm_dynstack_unwind_dynamic_state): New definitions.
  (scm_dynstack_unwind_1, scm_dynstack_wind_1): Add with-dynamic-state
  cases.
* libguile/memoize.c (push_dynamic_state, pop_dynamic_state)
  (do_push_dynamic_state, do_pop_dynamic_state): New definitions.
  (memoize, scm_init_memoize): Handle push-dynamic-state and
  pop-dynamic-state.
* libguile/vm-engine.c (push-dynamic-state, pop-dynamic-state): New
  opcodes.
* module/ice-9/boot-9.scm (with-dynamic-state): New definition in Scheme
  so that the push-dynamic-state and pop-dynamic-state always run in the
  VM.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/types.scm:
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
* module/system/vm/assembler.scm: Add support for with-dynamic-state to
  the compiler.
* test-suite/tests/fluids.test ("dynamic states"): Add basic tests.
* doc/ref/vm.texi (Dynamic Environment Instructions): Update.
2016-12-05 22:57:29 +01:00
Andy Wingo
aa84489d18 Reimplement dynamic states
There are two goals: one, to use less memory per dynamic state in order
to allow millions of dynamic states to be allocated in light-weight
threading scenarios.  The second goal is to prevent dynamic states from
being actively mutated in two threads at once.  This second goal does
mean that dynamic states object that escape into scheme are now copies
that won't receive further updates; an incompatible change, but one
which we hope doesn't affect anyone.

* libguile/cache-internal.h: New file.
* libguile/fluids.c (is_dynamic_state, get_dynamic_state)
  (save_dynamic_state, restore_dynamic_state, add_entry)
  (copy_value_table): New functions.
  (scm_i_fluid_print, scm_i_dynamic_state_print): Move up.
  (new_fluid): No need for a number.
  (scm_fluid_p: scm_is_fluid): Inline IS_FLUID uses.
  (fluid_set_x, fluid_ref): Adapt to dynamic state changes.
  (scm_fluid_set_x, scm_fluid_unset_x): Call fluid_set_x.
  (scm_swap_fluid): Rewrite in terms of fluid_ref and fluid_set.
  (swap_fluid): Use internal fluid_set_x.
  (scm_i_make_initial_dynamic_state): Adapt to dynamic state
  representation change.
  (scm_dynamic_state_p, scm_is_dynamic_state): Use new accessors.
  (scm_current_dynamic_state): Use make_dynamic_state.
  (scm_dynwind_current_dynamic_state): Use new accessor.
* libguile/fluids.h: Remove internal definitions.  Add new struct
  definition.
* libguile/threads.h (scm_i_thread): Use scm_t_dynamic_state for dynamic
  state.
* libguile/threads.c (guilify_self_1, guilify_self_2):
  (scm_i_init_thread_for_guile, scm_init_guile):
  (scm_call_with_new_thread):
  (scm_init_threads, scm_init_threads_default_dynamic_state): Adapt to
  scm_i_thread change.
  (scm_i_with_guile, with_guile): Remove "and parent" suffix.
  (scm_i_reset_fluid): Remove unneeded function.
* doc/ref/api-scheduling.texi (Fluids and Dynamic States): Remove
  scm_make_dynamic_state docs.  Update current-dynamic-state docs.
* libguile/vm-engine.c (vm_engine): Update fluid-ref and fluid-set!
  inlined fast paths for dynamic state changes.
* libguile/vm.c (vm_error_unbound_fluid): Remove now-unused function.
* NEWS: Update.
* module/ice-9/deprecated.scm (make-dynamic-state): New definition.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_make_dynamic_state): Move here.
* libguile/__scm.h (scm_t_dynamic_state): New typedef.
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_push_fluid):
  (scm_dynstack_unwind_fluid): Take raw dynstate in these internal
  functions.
* libguile/throw.c (catch): Adapt to dynstack changes.
2016-12-05 21:46:37 +01:00
Andy Wingo
dc2a560264 Deprecate dynamic roots
* libguile/root.h:
* libguile/root.c: Remove these files.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root)
  (scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate.

Remove all root.h usage, which was vestigial.

* module/ice-9/serialize.scm: Use (current-thread) instead
  of (dynamic-root).
2016-11-21 23:09:21 +01:00
Andy Wingo
a521440029 join-thread in Scheme
* module/ice-9/threads.scm (join-thread): Implement in Scheme.
  (call-with-new-thread): Arrange to record values in a weak table and
  signal the join cond.
  (with-mutex): Move up definition; call-with-new-thread needs it.  (How
  was this working before?)
* libguile/threads.c (guilify_self_1, guilify_self_2, do_thread_exit):
  Remove join queue management.
* libguile/threads.c (scm_join_thread, scm_join_thread_timed): Call out
  to Scheme.
  (scm_init_ice_9_threads): Capture join-thread var.
2016-11-14 21:50:41 +01:00
Andy Wingo
0f5a59b215 try-mutex in terms of mutex-lock
* libguile/threads.c (scm_try_mutex): Just call scm_lock_mutex_timed
  with a zero timeout.
* module/ice-9/threads.scm (try-mutex): Likewise.
2016-11-02 21:29:30 +01:00
Andy Wingo
eeeee3297b Remove thread cleanup facility
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Remove thread-cleanup docs.
* libguile/threads.c (guilify_self_1, do_thread_exit):
  (scm_set_thread_cleanup_x, scm_thread_cleanup): Remove these.
* libguile/threads.h (scm_i_thread): Remove cleanup_handler.
* module/ice-9/threads.scm:
* module/ice-9/deprecated.scm (thread-cleanup, set-thread-cleanup!):
  Remove.
* test-suite/tests/threads.test: Adapt to test cancel-thread return
  values and not test thread-cleanup procs.
2016-10-31 22:37:46 +01:00
Andy Wingo
a7114ced5f cancel-thread can take arguments
* doc/ref/api-scheduling.texi (Threads):
* module/ice-9/threads.scm (cancel-thread): Additional args to
  cancel-thread will be returned by the thread.
2016-10-31 22:11:01 +01:00
Andy Wingo
a04739b31a cancel-thread via asyncs, not pthread_cancel
* module/ice-9/threads.scm (cancel-tag): New variable.
  (cancel-thread): New Scheme function.
  (call-with-new-thread): Install a prompt around the thread.
* libguile/threads.h (scm_i_thread): Remove cancelled member.
* libguile/threads.c (scm_cancel_thread): Call out to Scheme.  Always
  available, and works on the current thread too.
  (scm_set_thread_cleanup_x, scm_thread_cleanup): Adapt.
  (scm_init_ice_9_threads): Capture cancel-thread var.
* doc/ref/api-scheduling.texi (Threads): Update.
* NEWS: Update.
2016-10-27 21:22:28 +02:00
Andy Wingo
f3bfe29235 Move call-with-new-thread to Scheme
* libguile/threads.c (scm_call_with_new_thread): Trampoline to Scheme.
  (launch_data, really_launch, scm_sys_call_with_new_thread): Simplify.
  (scm_init_ice_9_threads): Capture call-with-new-thread variable.
* module/ice-9/threads.scm (call-with-new-thread): Add implementation in
  Scheme.  Should allow for easier cancel-thread via prompt abort.
2016-10-26 22:50:26 +02:00
Andy Wingo
d74e0fed0d Move thread bindings to (ice-9 threads)
* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs.
* libguile/threads.c (scm_init_ice_9_threads): Rename from
  scm_init_thread_procs, make static.
  (scm_init_threads): Register scm_init_thread_procs extension.
* libguile/threads.h (scm_init_thread_procs): Remove decl.
* module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side
  effects occur early.
* module/ice-9/deprecated.scm (define-deprecated): Fix to allow
  deprecated bindings to appear in operator position.  Export deprecated
  bindings.
  (define-deprecated/threads, define-deprecated/threads*): Trampoline
  thread bindings to (ice-9 threads).
* module/ice-9/futures.scm: Use ice-9 threads.
* module/ice-9/threads.scm: Load scm_init_ice_9_threads extension.
  Reorder definitions and imports so that the module circularity
  with (ice-9 futures) continues to work.
* module/language/cps/intmap.scm:
* module/language/cps/intset.scm:
* module/language/tree-il/primitives.scm: Use (ice-9 threads).
* module/language/cps/reify-primitives.scm: Reify current-thread
  in (ice-9 threads) module.
* module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and
  adapt all users.  Use proper keywords in module definition form.
* test-suite/tests/filesys.test (test-suite):
* test-suite/tests/fluids.test (test-suite):
* test-suite/tests/srfi-18.test: Use ice-9 threads.
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Update.
* doc/ref/posix.texi (Processes): Move current-processor-count and
  total-processor-count docs to Threads.
2016-10-23 22:29:44 +02:00
Andy Wingo
56b490a4dd Deferred module observers via a parameter
* module/ice-9/boot-9.scm (module-defer-observers): Instead of being a
  global flag, change to be a parameter.
  (module-defer-observers-mutex, module-defer-observers-table): Remove.
  (module-modified): Adapt.
  (call-with-deferred-observers): Adapt.  Allow nested called.
2016-10-23 12:17:19 +02:00
Andy Wingo
32f309d5ce Compiler support for atomics
* doc/ref/vm.texi (Inlined Atomic Instructions): New section.
* libguile/vm-engine.c (VM_VALIDATE_ATOMIC_BOX, make-atomic-box)
  (atomic-box-ref, atomic-box-set!, atomic-box-swap!)
  (atomic-box-compare-and-swap!): New instructions.
* libguile/vm.c: Include atomic and atomics-internal.h.
  (vm_error_not_a_atomic_box): New function.
* module/ice-9/atomic.scm: Register primitives with the compiler.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  support for atomic ops.
* module/language/cps/effects-analysis.scm: Add comment about why no
  effects analysis needed.
* module/language/cps/reify-primitives.scm (primitive-module): Add case
  for (ice-9 atomic).
* module/language/tree-il/primitives.scm (*effect-free-primitives*):
  (*effect+exception-free-primitives*): Add atomic-box?.
* module/system/vm/assembler.scm: Add new instructions.

* test-suite/tests/atomic.test: Test with compilation and
  interpretation.
2016-09-06 12:18:35 +02:00
Andy Wingo
3425290a7b Add atomic boxes
* doc/ref/api-scheduling.texi (Atomics): New manual section.
* libguile.h: Include atomic.h.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add atomic.
* libguile/atomic.c:
* libguile/atomic.h: New files.
* libguile/atomics-internal.h (scm_atomic_set_scm, scm_atomic_ref_scm)
  (scm_atomic_swap_scm, scm_atomic_compare_and_swap_scm): New
  facilities.
* libguile/goops.c (class_atomic_box, scm_sys_goops_early_init): Add
  support for <atomic-box>.  Remove duplicate <keyword> fetch.
* libguile/init.c (scm_i_init_guile): Call scm_register_atomic_box.
* libguile/print.c (iprin1): Add atomic box case.
* libguile/tags.h (scm_tc7_atomic_box): New tag.
* libguile/validate.h (SCM_VALIDATE_ATOMIC_BOX): New macro.
* module/Makefile.am (SOURCES): Add ice-9/atomic.scm.
* module/ice-9/atomic.scm: New file.
* module/oop/goops.scm (<atomic-box>): New var.
2016-09-06 11:16:53 +02:00
Andy Wingo
2fa2e50a0f Add file descriptor finalizers
* doc/ref/posix.texi (Ports and File Descriptors): Document new
  interfaces.
* libguile/filesys.c (scm_close, scm_close_fdes)
* libguile/fports.c (fport_close):
* libguile/ioext.c (scm_primitive_move_to_fdes): Call
  scm_run_fdes_finalizers.
* module/ice-9/fdes-finalizers.scm:
* test-suite/tests/fdes-finalizers.test:
* libguile/fdes-finalizers.h:
* libguile/fdes-finalizers.c: New files.
* module/Makefile.am:
* test-suite/Makefile.am:
* libguile/Makefile.am:
* libguile.h:
* libguile/init.c: Wire up new files.
2016-08-30 23:35:10 +02:00
Andy Wingo
1a1c3bbe59 Implement R6RS custom binary input/output ports
* NEWS: Add new feature.
* doc/ref/r6rs.texi (rnrs io ports):
* doc/ref/api-io.texi (Custom Ports): Document new procedure.
* libguile/r6rs-ports.h:
* libguile/r6rs-ports.c (make_custom_binary_input_output_port)
  (scm_make_custom_binary_input_output_port)
  (custom_binary_input_output_port_random_access_p)
  (initialize_custom_binary_input_output_ports)
  (scm_init_r6rs_ports): Implement custom binary input/output ports.
* module/rnrs/io/ports.scm (rnrs):
* module/ice-9/binary-ports.scm (ice-9): Export
  make-custom-binary-input/output-port.
2016-08-04 22:29:51 +02:00
Andy Wingo
a62d46ffff psyntax can trace expand-time changes to the current module
* module/ice-9/psyntax.scm (expand-top-sequence): Support expand-time
  changes to the current module.
* module/ice-9/psyntax-pp.scm: Regenerate.
2016-06-27 22:54:04 +02:00
Taylan Ulrich Bayırlı/Kammer
d5d7e30348 Fix 'monitor' macro.
* module/ice-9/threads.scm (monitor-mutex-table)
(monitor-mutex-table-mutex, monitor-mutex-with-id): New variables.
(monitor): Fix it.
2016-06-27 09:32:30 +02:00
Andy Wingo
3e719e0a35 Add -Wmacro-use-before-definition
* module/ice-9/boot-9.scm (%auto-compilation-options):
* am/guilec (GUILE_WARNINGS): Add -Wmacro-use-before-definition.
* module/language/tree-il/analyze.scm (unbound-variable-analysis): Use
  match-lambda.
  (<macro-use-info>, macro-use-before-definition-analysis): New
  analysis.
* module/system/base/message.scm (%warning-types): Add
  macro-use-before-definition warning type.
* module/language/tree-il/compile-cps.scm (%warning-passes): Add
  support for macro-use-before-definition.
2016-06-25 18:08:28 +02:00
Andy Wingo
ff5cafc77d Prevent (@ (ice-9 boot-9) x)
* module/ice-9/boot-9.scm: Prevent re-loading, perhaps via (@ (ice-9
  boot-9) foo).  (ice-9 boot-9) isn't a module.  Fixes #21801.
2016-06-24 17:24:08 +02:00
Andy Wingo
5ca24b6ba1 Fix include-from-path when file found in relative path
* module/ice-9/psyntax.scm (include-from-path): Canonicalize result of
  %search-load-path.  Otherwise a relative path passed to `include'
  would be treated as relative to the directory of the file that
  contains the `include-from-path'.  Fixes #21347.
* module/ice-9/psyntax-pp.scm: Regenerate.
2016-06-24 10:40:09 +02:00
Andy Wingo
3df22933b6 Static default for define-module #:duplicates
* module/ice-9/boot-9.scm (define-module*): Leaving off #:duplicates
  defaults to installing the duplicate binding handlers specified in the
  manual, not the value of some other dynamic parameter.
  (default-duplicate-binding-procedures):
  (default-duplicate-binding-handler): Instead of closing over a
  separate fluid, close over the handlers of the current module.  That
  way when a user does (default-duplicate-binding-handler ...) in a
  script, then it applies to the right module.
2016-06-23 17:56:27 +02:00
Andy Wingo
04d87db927 Fix default-duplicate-binding-handlers for compilation
* module/ice-9/boot-9.scm (define-module*): Capture value of
  `default-duplicate-binding-procedures' when the module is created.
  Fixes #20093.
2016-06-23 17:13:41 +02:00
Andy Wingo
d0d14f410d Importing modules with #:select no longer grovels private bindings
* module/ice-9/boot-9.scm (resolve-interface): Don't look in private
  interface for #:select bindings.  Fixes #17418.
* module/system/repl/coop-server.scm: Don't rely on bad #:select
  behavior.
* NEWS: Add entry.
2016-06-21 16:01:50 +02:00
Taylan Ulrich Bayırlı/Kammer
8ffcd28fde Fix SRFI-2 (and-let*) implementation.
* module/ice-9/and-let-star.scm (%and-let*): Re-implemented this in a
  more verbose but accurate way.
2016-06-21 13:40:01 +02:00
Andy Wingo
7142005a05 Skip incompatible .go files
* libguile/load.c (load_thunk_from_path, try_load_thunk_from_file): New
  functions.
  (search_path): Simplify.
  (scm_primitive_load_path, scm_init_eval_in_scheme): Use the new
  functions to load compiled files.
* module/ice-9/boot-9.scm (load-in-vicinity): Skip invalid .go files.

Inspired by a patch from Jan Nieuwenhuizen <janneke@gnu.org>.
2016-06-12 10:32:45 +02:00
Andy Wingo
6788faba7a Non-blocking accept/connect Scheme support
* module/ice-9/sports.scm (accept, connect): New Scheme functions.
2016-06-09 11:00:35 +02:00
Andy Wingo
d8067213dc put-char in Scheme
* libguile/ports.c (scm_port_encode_char): New function.
* module/ice-9/ports.scm (port-encode-char): Export port-encode-char to
  the internals module.
* module/ice-9/sports.scm (put-char): New function.
  (port-bindings): Add put-char and put-string.
2016-06-09 10:59:02 +02:00
Andy Wingo
c7c11f3af9 Update port documentation, rename sports to suspendable ports
* module/ice-9/suspendable-ports.scm: Rename from ice-9/sports.scm, and
  adapt module names.  Remove exports that are not related to the
  suspendable ports facility; we want people to continue using the port
  operations from their original locations.  Add put-string to the
  replacement list.
* module/Makefile.am: Adapt to rename.
* test-suite/tests/suspendable-ports.test: Rename from sports.test.
* test-suite/Makefile.am: Adapt to rename.
* module/ice-9/textual-ports.scm (unget-char, unget-string): New
  functions.
* doc/ref/api-io.texi (Textual I/O, Simple Output): Flesh out
  documentation.
  (Line/Delimited): Undocument write-line, read-string, and
  read-string!.  This is handled by (ice-9 textual-ports).
  (Bytevector Ports): Fix duplicated section.
  (String Ports): Move the note about encodings down to the end.
  (Custom Ports): Add explanatory text.  Remove mention of C functions;
  they should use the C port interface.
  (Venerable Port Interfaces): Add text, and make documentation refer to
  recommended interfaces.
  (Using Ports from C): Add documentation.
  (Non-Blocking I/O): Document more fully and adapt to suspendable-ports
  name change.
2016-06-09 10:50:32 +02:00
Andy Wingo
4ed9f6c29c Add (ice-9 textual-ports)
* module/ice-9/textual-ports.scm: New module.
* module/Makefile.am: Add new module.
2016-06-08 07:44:43 +02:00
Andy Wingo
4bceba876b put-char, put-string in (ice-9 ports internals)
* libguile/ports.h (scm_put_char):
* libguile/ports.c (scm_put_char): New function.
  (scm_put_string): Add docstrings, and expose to the internal ports
  module.
* module/ice-9/ports.scm (put-char, put-string): Expose these bindings
  only through the internals module.
2016-06-08 07:44:16 +02:00
Andy Wingo
9454068a54 put-string in Scheme
* module/ice-9/ports.scm: Export port-encode-chars and
  port-clear-stream-start-for-bom-write via the internals module.
* module/ice-9/sports.scm (put-string): New function.
2016-06-01 12:07:30 +02:00
Andy Wingo
1123002a9e Add port-line-buffered?
* libguile/ports.c (scm_port_line_buffered_p): New function.
* module/ice-9/ports.scm: Plump port-line-buffered? and
  port-auxiliary-write-buffer through to the internals module
2016-05-25 21:56:19 +02:00
Andy Wingo
48dbadd8e6 Speed golf on Scheme put-u8, put-bytevector
* module/ice-9/sports.scm (put-u8, put-bytevector): Speed hack.
2016-05-24 08:37:57 +02:00
Andy Wingo
7c8b80e076 Add put-u8 implementation in Scheme
* module/ice-9/sports.scm (put-u8): Add implementation.
  (port-bindings): Add put-u8.
2016-05-24 08:27:29 +02:00
Andy Wingo
ba91741063 `put-bytevector' in Scheme
* module/ice-9/sports.scm (flush-input): New helper.
  (put-bytevector): New function.
  (port-bindings): Add put-bytevector.
2016-05-24 08:06:04 +02:00