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

1971 commits

Author SHA1 Message Date
Ludovic Courtès
ab975cf592 futures: Add a record printer.
* module/ice-9/futures.scm: Add a record printer for <future>.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
f2fb5e5328 futures: Keep futures unlocked while they are processing.
* module/ice-9/futures.scm (<future>)[completion]: New field.
  [done?]: Rename to...
  [state]: ... this.  Change `set-future-done?!' to
  `set-future-state!', and `future-done?' to `future-state'.
  (make-future): Initialize the `completion' field to 'queued.
  (with-mutex): New macro.
  (process-future!): Remove `set-future-done?!' call.
  (process-futures): Check `future-state'.  Unlock FUTURE's mutex before
  processing it.  Broadcast FUTURE's `completion' cond. var. when done.
  (touch): Likewise.
2012-11-21 23:33:30 +01:00
Ludovic Courtès
67768115d7 doc: Fix typo in `set-record-type-printer!' doc.
* module/srfi/srfi-9/gnu.scm (set-record-type-printer!): Change the
  parameter name to `proc'.
* doc/ref/api-compound.texi (SRFI-9 Records): Update accordingly.
2012-11-17 15:34:49 +01:00
Andreas Rottmann
3ae5a02f1d Add missing R6RS `open-file-input/output-port' procedure
* module/rnrs/io/port.scm (r6rs-open): New internal helper procedure for
  opening files.
  (open-file-input-port, open-file-output-port): Make use of
  `r6rs-open'.
  (open-file-input/output-port): Implement in terms of `r6rs-open',
  add to exported identifiers list.

* module/rnrs.scm (open-file-input/output-port): Add to exported
  identifiers.

* test-suite/tests/r6rs-ports.test (test-input-file-opener): New
  procedure, collects several tests for opening file input ports.
  ("7.2.7 Input Ports"): Use `test-input-file-opener' for checking
  `open-file-input-port'.
  (test-output-file-opener): New procedure, collects several tests for
  opening file output ports.
  ("8.2.10 Output ports"): Use `test-output-file-opener' for checking
  `open-file-output-port'.
  ("8.2.13 Input/output ports"): New test prefix, making use of both
  `test-input-file-opener' and `test-output-file-opener' to check
  `open-file-input/output-port'.
2012-11-12 20:47:57 +01:00
Mark H Weaver
3d01c19a78 Change the argument order of 'set-fields' to match that of 'set-fields'.
* module/srfi/srfi-9/gnu.scm (set-fields): Swap order of first two
  arguments.

* test-suite/tests/srfi-9.test: Update tests.
2012-11-10 16:05:24 -05:00
Mark H Weaver
4695483901 Add system/base/ck.scm to SYSTEM_BASE_SOURCES in module/Makefile.am.
* module/Makefile.am (SYSTEM_BASE_SOURCES): Add system/base/ck.scm.
2012-11-10 14:35:49 -05:00
Mark H Weaver
be05b33609 Futures: Avoid creating the worker pool more than once.
* module/ice-9/futures.scm (%create-workers!): Use 'with-mutex' in case
  an exception is thrown.  Within the critical section, check to make
  sure the worker pool hasn't already been created by another thread.
2012-11-10 10:08:19 -05:00
Mark H Weaver
92fac8c056 Improve error for set-fields paths leading to different types.
* module/system/base/ck.scm: New module.

* module/srfi/srfi-9.scm: Import (system base ck).

  (getter-type, getter-index, getter-copier): Convert incoming argument
  convention to CK form.

  (define-tagged-inlinable): Convert return value convention for key
  lookup to CK form.

* module/srfi/srfi-9/gnu.scm: Import (system base ck).
  Rename '%set-fields-unknown-getter' to 'unknown-getter'.

  (c-list, c-same-type-check): New macros.

  (%set-fields): Using the CK abstract machine, arrange to check (at
  macro expansion time) that all of the getters in head position
  correspond to the same record type.

* test-suite/tests/srfi-9.test: Add test.
2012-11-10 01:37:20 -05:00
Mark H Weaver
f31a076232 Improve error messages for invalid record definitions.
* module/srfi/srfi-9.scm (%define-record-type): Accept additional 'form'
  parameter which contains the original form of 'define-record-type' or
  'define-immutable-record-type'.  Add elaborate pattern guard which
  raises descriptive syntax errors for specific errors, and a fallback
  pattern to catch anything else.
  (define-record-type): Pass 'form' parameter to %define-record-type.

* module/srfi/srfi-9/gnu.scm (define-immutable-record-type): Pass 'form'
  parameter to %define-record-type.

* test-suite/tests/srfi-9.test: Add tests.
2012-11-09 23:05:42 -05:00
Mark H Weaver
fe040dd138 Fix record constructor in getopt-long.
* module/ice-9/getopt-long.scm (%make-option-spec): Fix the formal
  argument list to match the actual fields present.
  (make-option-spec): Update to match the fixed %make-option-spec.
2012-11-08 21:53:36 -05:00
Mark H Weaver
d9e368979b Implement functional record setters.
Written in collaboration with Ludovic Courtès <ludo@gnu.org>

* module/srfi/srfi-9.scm: Internally, rename 'accessor' to 'getter'
  and 'modifier' to 'setter'.

  (define-tagged-inlinable, getter-type, getter-index, getter-copier,
  %%on-error, %%set-fields): New macros.

  (%define-record-type): New macro for creating both mutable and
  immutable records, and containing a substantially rewritten version of
  the code formerly in 'define-record-type'.

  (define-record-type): Now just a wrapper for '%define-record-type'.

  (throw-bad-struct, make-copier-id): New procedures.

* module/srfi/srfi-9/gnu.scm (define-immutable-record-type, set-field,
  and set-fields): New exported macros.

  (collate-set-field-specs): New procedure.

  (%set-fields-unknown-getter, %set-fields): New macros.

* test-suite/tests/srfi-9.test: Add tests.  Rename getters and setters
  in existing tests to make the functional setters look better.
2012-11-08 19:20:28 -05:00
Ludovic Courtès
b29b2c87b4 Fix copyright years in `futures.scm'.
* module/ice-9/futures.scm: Update copyright years.
2012-11-05 19:16:09 +01:00
Mark H Weaver
acc1d8e37a Preserve additional R6RS library name components after srfi :n
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface):
  (srfi :n ...) -> (srfi srfi-n ...) instead of (srfi srfi-n).
2012-11-04 23:53:16 -05:00
Ludovic Courtès
134c95f1e6 futures: Have workers work when futures are available.
Reported by David Pirotte.

* module/ice-9/futures.scm (process-futures): Wait on %FUTURES-AVAILABLE
  only when %FUTURES is empty.

  The problem was obvious when running (begin (use-modules (ice-9
  threads)) (par-map 1+ (iota 400000))) : eventually, only the main
  thread would do the work, while the others would remain idle, waiting
  on %FUTURES-AVAILABLE.
2012-11-03 01:05:19 +01:00
Ludovic Courtès
139ce19474 scandir: Use lstat' instead of stat'.
* module/ice-9/ftw.scm (scandir): Use `lstat', not `stat'.

* test-suite/tests/ftw.test ("scandir")["symlink to directory"]: New
  test.
2012-11-01 00:48:59 +01:00
Mark H Weaver
bf9eb54aab Implement SRFI-105 curly infix expressions.
* libguile/private-options.h: Add SCM_CURLY_INFIX_P macro, and increment
  SCM_N_READ_OPTIONS.

* libguile/read.c (sym_nfx, sym_bracket_list, sym_bracket_apply): New
  variables.
  (scm_read_opts): Add curly-infix reader option.  Reformat to comply
  with GNU coding standards.
  (scm_t_read_opts): Add curly_infix_p and neoteric_p fields.
  (init_read_options): Initialize new fields.
  (CHAR_IS_DELIMITER): Add '{', '}', '[', and ']' as delimiters if
  curly_infix_p is set.

  (set_port_square_brackets_p, set_port_curly_infix_p): New functions.

  (read_inner_expression): New function which contains the code that was
  previously in 'scm_read_expression'.  Handle curly braces when
  curly_infix_p is set.  If curly_infix_p is set and square_brackets_p
  is unset, follow the Kawa convention: [...] => ($bracket-list$ ...)

  (scm_read_expression): New function body to handle neoteric
  expressions where appropriate.

  (scm_read_shebang): Handle the new reader directives: '#!curly-infix'
  and the non-standard '#!curly-infix-and-bracket-lists'.

  (scm_read_sexp): Handle curly infix lists.

* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-105 feature
  identifier.

* doc/ref/srfi-modules.texi (SRFI-105): Add stub doc for SRFI-105.

* doc/ref/api-evaluation.texi (Scheme Read): Add documentation for the
  'curly-infix' read option, and the '#!curly-infix' and
  '#!curly-infix-and-bracket-lists' reader directives.

* doc/ref/api-options.texi (Runtime Options): Add 'curly-infix' to the
  list of read options.

* test-suite/Makefile.am: Add tests/srfi-105.test.

* test-suite/tests/srfi-105.test: New file.
2012-10-26 19:52:32 -04:00
Ian Price
591065954c Fix @@ usage in --listen option
* module/ice-9/command-line.scm (compile-shell-switches): Fix usage of
  @@, which no longer supports arbitrary expressions, only identifiers.
2012-10-18 00:08:13 -04:00
Mark H Weaver
495797ceb5 Improve formatting of options help given long option names
* module/ice-9/boot-9.scm (define-option-interface): When printing
  options help, e.g. for (read-options 'help), expand the width of the
  first column by another tab stop, to accommodate option names of up to
  23 characters.
2012-10-17 04:48:40 -04:00
Ludovic Courtès
f865ffaab1 web: Fix possible file descriptor leak in `open-socket-for-uri'.
* module/web/client.scm (open-socket-for-uri): Always close S in the
  `system-error' handler.
2012-10-13 21:13:10 +02:00
Ludovic Courtès
d74fcce9b9 web: Pass `AI_NUMERICSERV' when given a port number.
* module/web/client.scm (open-socket-for-uri)[addresses]: Pass
  AI_NUMERICSERV as the `getaddrinfo' hint when (uri-port URI) is true.
2012-10-12 23:21:39 +02:00
Ludovic Courtès
2663411bd7 web: Change `http-get' to try all the addresses for the given URI.
* module/web/client.scm (open-socket-for-uri): Try all the addresses
  returned by `getaddrinfo' until one succeeds.
2012-10-12 23:21:39 +02:00
Mark H Weaver
8b22ced1c9 Revert "Preserve keyword identifier in 'syntax-rules' and 'define-syntax-rule'"
This reverts commit 3e3d32dd9b.
2012-10-10 13:13:19 -04:00
Mark H Weaver
3e3d32dd9b Preserve keyword identifier in 'syntax-rules' and 'define-syntax-rule'
* module/ice-9/psyntax-pp.scm (syntax-rule, define-syntax-rule):
  Preserve the keyword identifier.

* module/ice-9/psyntax-pp.scm: Regenerate.
2012-10-08 14:08:43 -04:00
Mark H Weaver
75a5de18a0 Simplify calls to 'eqv?' when one argument is an immediate constant.
* module/language/tree-il/primitives.scm (maybe-simplify-to-eq): New
  helper procedure shared by expanders for 'eqv?' and 'equal?'.
  (*primitive-expand-table*): Add expansion rule for 'eqv?'.

* test-suite/tests/tree-il.test ("primitives"): Add tests.
2012-10-08 11:56:10 -04:00
Mark H Weaver
bcf87e35e1 Don't simplify 'equal?' to 'not' or 'null?'.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Don't simplify 'equal?' to 'not' or 'null?', but only to 'eq?'.

* test-suite/tests/tree-il.test ("primitives"): Adjust tests.
2012-10-08 00:37:09 -04:00
Mark H Weaver
ebd363161e Don't simplify 'equal?' to 'eq?' when constant is an *inexact* small integer.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Refine test for fixnums to verify that the small integer is exact.

* test-suite/tests/tree-il.test ("primitives"): Add test.
2012-10-07 23:57:13 -04:00
Ludovic Courtès
2446f8e126 Simplify calls to `equal?' when one argument is a constant.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Add
  expansion rules for `equal?', when called with one constant and
  another argument.

* test-suite/tests/tree-il.test (pass-if-primitives-resolved): New
  macro.
  ("primitives"): New test prefix.
2012-10-06 22:34:00 +02:00
Chris K. Jester-Young
d6e1c8bfdb In fold-matches, set regexp/notbol unless matching string start.
* module/ice-9/regex.scm (fold-matches): Set regexp/notbol if the
  starting position is nonzero.
* test-suite/tests/regexp.test (fold-matches): Check that when
  matching /^foo/ against "foofoofoofoo", only one match results.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2012-09-26 23:46:05 +02:00
Ludovic Courtès
b6aedd68bc Don't stat(2) and access(2) the .go location before using it.
* module/system/base/compile.scm (ensure-directory): Rename to...
  (ensure-directory): ... this.  Update callers.  When ERRNO is EEXIST,
  assume DIR is a writable directory instead of calling `stat' and
  `access?' again.  Fixes UID/EUID mismatches for setuid binaries.
  Reported by rixed@happyleptic.org at
  <http://lists.gnu.org/archive/html/guile-user/2012-06/msg00023.html>.
2012-09-11 23:44:59 +02:00
Ludovic Courtès
e7350baf1e Rewrite SRFI-31 in terms of `syntax-rules'.
* module/srfi/srfi-31.scm: Use `#:export' instead of `#:export-syntax'.
  (rec): Rewrite using `syntax-rules'.

* test-suite/tests/srfi-31.test ("rec special form"): Change exception
  type to EXCEPTION:SYNTAX-PATTERN-UNMATCHED.
2012-09-11 23:39:32 +02:00
Ian Price
4aaceda29f `define-public' is no a longer curried definition by default.
* module/ice-9/boot-9.scm (define-public): Remove currying functionality.
* module/ice-9/curried-definitions.scm (define-public): New export.
2012-09-06 13:08:33 +01:00
Ian Price
d6bd182618 ISO 8601 time format specifies zero padding for hours, not blank padding.
* doc/ref/srfi-modules.texi ("SRFI-19 Date to string"): Fix iso 8601 format strings.
* module/srfi/srfi-19.scm (directives): Fix iso 8601 format strings.
2012-08-27 00:10:44 +02:00
Ian Price
866210bf24 Fix uri-encoding for strings with no unreserved chars
* module/web/uri.scm (uri-encode): Change test to check for unreserved
  chars instead of reserved chars.
* test-suite/tests/web-uri.test ("encode"): Add test.
2012-08-26 23:36:36 +02:00
Ian Price
b401fe7169 Fix uri-encoding for octets 0-15
* module/web/uri.scm (uri-encode): All encoded octets should be of the
  form % HEXDIGIT HEXDIGIT.
* test-suite/tests/web-uri.test ("encode"): Add test.
2012-08-26 23:35:33 +02:00
Andy Wingo
dc7a9cefbf more robust texinfo alias handling
* module/texinfo.scm (command-spec): Resolve aliases here.
  (complete-start-command, make-command-parser):
  (make-dom-parser, parse-environment-args): Reload command after
  resolving spec, so we get the alias target.
2012-08-25 14:11:45 +02:00
Ludovic Courtès
6c9220064d Micro-optimize (ice-9 format).
* module/ice-9/format.scm (format): Use `call-with-output-string'
  instead of `with-output-to-string'.
2012-08-21 00:36:50 +02:00
Ian Price
64ead01db7 Document and export `declare-opaque-header!'
* module/web/http.scm (declare-opaque-header!): Add docstring. New export.
* doc/ref/web.texi (HTTP): Add documentation.
2012-07-06 22:18:13 +02:00
Ian Price
312e79f8d5 Add HTTP Chunked Encoding support to web modules.
* doc/ref/web.texi(Transfer Codings): New subsection for transfer codings.
* module/web/http.scm(make-chunked-input-port,
  make-chunked-output-port): New procedures.
* module/web/response.scm (read-response-body): Handle chunked responses.
* test-suite/tests/web-response.test: Add test.
* test-suite/tests/web-http.test: Add tests.

afd
2012-07-06 22:18:12 +02:00
Mark H Weaver
8210c8538a Fix @ and @@ to not capture lexicals; new @@ @@ form for R6RS libraries
* module/ice-9/psyntax.scm (@): Return top-wrap instead of the wrap
  applied to the '@' form, so that the symbol will be interpreted as a
  top-level identifier and never refer to any lexical variable.

  (@@): Change the syntax used to support R6RS 'library' forms to:
  (@@ @@ (mod ...) body).  Change the behavior of the documented
  (@@ (mod ...) id) form to be the same as that of @, except for the use
  of 'private' instead of 'public' in the psyntax mod: use syntax->datum
  on the identifier, and return top-wrap instead of the wrap applied to
  the '@@' form.

  This fixes <http://bugs.gnu.org/10756> reported by Ludovic Courtès.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/r6rs-libraries.scm (library): Use '@@ @@' syntax instead
  of the older '@@' syntax.

* test-suite/tests/syncase.test (changes to expansion environment): Use
  '@@ @@' syntax.

* module/Makefile.am: Add explicit dependencies for boot-9.go on the
  files that it includes: quasisyntax.scm and r6rs-libraries.scm.
2012-07-06 20:12:50 +02:00
Andy Wingo
5f8d67ad09 simplify %condition-type-vtable
* module/srfi/srfi-35.scm (%condition-type-vtable): Use make-vtable
  instead of make-vtable-vtable.
2012-07-06 18:32:14 +02:00
Andy Wingo
581bd72a7d record-type-vtable is not a new root of the vtable hierarchy
* module/ice-9/boot-9.scm (record-type-vtable): Simplify to use
  make-vtable instead of make-vtable-vtable.
2012-07-06 18:32:14 +02:00
Daniel Krueger
e1fb0e811b fixed repl command ,describe to also handle syntax 2012-07-06 14:35:10 +02:00
Andy Wingo
3fabb2d2be more uri-related ipv6 fixes
* module/web/uri.scm (ipv6-regexp): IPv6 numeric addresses do not have
  brackets.  It's only in URIs that they have them.
  (ipv6-host-pat, authority-regexp, parse-authority): Refactor ipv6
  detection to fix a bug with |, and to extract IPv6 hosts from their
  brackets.  This way we can pass the uri-host directly to inet-pton.
  (uri->string): If the host contains a `:', assume it is ipv6 and add
  brackets.

* test-suite/tests/web-uri.test ("build-uri"): Adapt tests to assume
  that the address returned by uri-host and passed to build-uri #:host
  does not have brackets.
2012-07-06 13:13:19 +02:00
Daniel Hartwig
81e7210f14 enhance IPv6 support
* module/web/uri.scm (valid-host?): Support dotted-quad notation
  in IPv6 addresses.
  (parse-authority): Support IPv6 literals.
* test-suite/tests/web-uri.test: Add and fix tests.
2012-07-06 12:33:41 +02:00
Daniel Hartwig
274e2eecf1 support URIs with domain names starting with numbers
* module/web/uri.scm (valid-host?): Fix regexp to support
domain names starting with numbers.
* test-suite/tests/web-uri.scm: Add tests for above and
IP literals.
2012-07-06 12:33:16 +02:00
Andy Wingo
fc835b1b14 better procedure-arguments for interpreted procs with opt, rest, kwargs
* module/ice-9/session.scm (procedure-arguments): Arrange to interpret
  numbers in the "req" and "opt" positions of an 'arglist as N arguments
  with unknown name.

* module/ice-9/eval.scm (primitive-eval): Set 'arglist on "complex"
  procedures.  Fixes http://bugs.gnu.org/10922.

* test-suite/tests/session.test ("procedure-arguments"): Add a test.
2012-07-06 12:19:12 +02:00
Andy Wingo
13e3d3d95d fix `vector' instruction emission for big vectors
* module/language/glil/compile-assembly.scm (dump-constants): Only use
  the `vector' instruction for vectors whose length can fit in 16 bits.

  Fixes http://bugs.gnu.org/11087.
2012-07-05 23:26:38 +02:00
Andy Wingo
b8a5606b10 fix-letrec uses effects.scm for effects analysis
* module/language/tree-il/fix-letrec.scm: Use effects.scm for effects
  analysis, instead of primitives.scm.
  (simple-expression?, partition-vars): Adapt.
2012-07-05 20:40:56 +02:00
Andy Wingo
997ed30070 simplify one kind of degenerate prompt
* module/language/tree-il/peval.scm (<operand>): Instead of having a
  `residualize?' field, have it be a use count.
  (peval): Adapt to <operand> change.  Add function to kill uses of an
  operand.  Use it in the <prompt> inliner.  Add another kind of
  degenerate prompt to elide.  We should really switch to CPS though, as
  that will allow us to contify more aggressively.

* test-suite/tests/peval.test ("partial evaluation"): Adapt (while #t
  #t) test, which was sensitive to how far the recursive inlining got.
  Add a test for the degenerate prompt elision.
2012-07-05 20:39:16 +02:00
Andy Wingo
37081d5d4b fix bugs in effects analysis of "effect+exception-free-primitives"
* module/language/tree-il/effects.scm (make-effects-analyzer): Be more
  precise regarding the effects of the so-called
  effect+exception-free-primitives: now we check their arities.

* test-suite/tests/cse.test ("cse"): Add a test that we don't
  elide (cons 1 2 3) in effect context.
2012-07-05 20:34:28 +02:00