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

1636 commits

Author SHA1 Message Date
Ian Price
5f09e4ba3c Fix hygiene issues with `define-record-type'
* module/rnrs/records/syntactic.scm (define-record-type0, process-fields):
  Preserve hygiene of record clauses.

* test-suite/tests/r6rs-records-syntactic.test ("record hygiene"):
  Add tests.
2011-06-19 21:41:39 +02:00
Andy Wingo
c245d16a5b current-language really defaults to Scheme.
* module/system/base/language.scm (current-language): Default to 'scheme
  here, rather than relying on *current-language* always being bound.

Thanks to 亚光唐 <texnician@gmail.com> for the report.
2011-06-17 19:57:24 +02:00
Andy Wingo
b88fef5519 fix invalid transformation of (values x) -> x, (+ x) -> x, etc
* module/language/tree-il/primitives.scm (+, *, cons*): In the case of
  just one argument (the identity case), expand to (values x) instead of
  just x.  Fixes values truncation in that case.
  (values): Likewise remove (values x) -> x translation, as the compiler
  will do it for us, and this fixes (values (values 1 2)).

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Handle
  `values' in a push context here.

* test-suite/tests/tree-il.test ("values"): Add some tests.
2011-06-17 19:42:55 +02:00
Andy Wingo
f86f748db2 add -Wformat to %auto-compilation-options
* module/ice-9/boot-9.scm (%auto-compilation-options): Add -Wformat to
  the default warning set.
2011-06-17 19:16:16 +02:00
Andy Wingo
669ea4ebff better messages on failed autocompilation
* libguile/load.c (auto_compile_catch_handler):
* module/ice-9/boot-9.scm (load-in-vicinity): Nicer messages when
  autocompilation fails.
2011-06-17 18:08:06 +02:00
Andy Wingo
0083cb5ec4 fix self tail recursion to different case-lambda clauses
http://savannah.gnu.org/bugs/?33362

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Rename
  from flatten, as it really just takes a particular case.  Instead of
  iteratively compiling lambda cases through `comp', tail-call through
  flatten-lambda-case.  This allows code to see which case it's being
  compiled in.  Take advantage of that to limit the self-tail-call
  optimization to self-calls to the same case -- otherwise we might be
  jumping to a label without having reserved the right number of
  locals.
  (flatten-lambda): Adapt the caller.

* test-suite/tests/compiler.test ("case-lambda"): Add a test.
2011-06-17 17:08:06 +02:00
Andreas Rottmann
933c6eb795 Silence warnings for variables created by `generate-temporaries'
* module/ice-9/psyntax.scm (generate-temporaries): Give temporaries the
  current module, so that they may be bound at the top level.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-06-17 10:43:24 +02:00
Andy Wingo
b8b0659879 rename guile-tools' to guild'
* configure.ac: Look for ln -s.  Write out `guild' instead of
  `guile-tools'.

* meta/Makefile.am (install-data-hook): Link the installed `guild' to
  the backward-compatible `guile-tools' name.
  (bin_SCRIPTS, EXTRA_DIST): Fix up for guild change.

* meta/guild.in: Moved here from `guile-tools.in'.

* doc/ref/Makefile.am (autoconf-macros.texi):
* doc/ref/api-evaluation.texi (Compilation):
* doc/ref/autoconf.texi (Autofrisk, Using Autofrisk):
* doc/ref/mod-getopt-long.texi (getopt-long Reference):
* doc/ref/tools.texi (Miscellaneous Tools, Executable Modules): Minimal
  doc update.

* .gitignore:
* am/guilec (.scm.go):
* libguile/Makefile.am (snarf2checkedtexi):
* module/Makefile.am (ice-9/psyntax-pp.go): Update makefiles, etc.

* module/scripts/README:
* module/scripts/lint.scm:
* module/scripts/list.scm: Update commentaries.
2011-05-31 22:01:47 +02:00
Andy Wingo
34ed9dfd1f compile-bytecode uses target-endianness
* module/language/assembly/compile-bytecode.scm (compile-bytecode):
  Use target-endianness, from (system base target).
2011-05-31 11:18:28 +02:00
Andy Wingo
42090217cf add (system base target)
* module/Makefile.am:
* module/system/base/target.scm: Add a minimal module to parameterize
  the target system type and inspect properties on it like cpu, vendor,
  os, endianness, and word size.
2011-05-31 11:18:28 +02:00
Andreas Rottmann
0687e826a1 rnrs io ports: fix port encoding when opening file ports
* module/rnrs/io/ports.scm (open-file-input-port)
  (open-file-output-port): Ensure the resulting ports are binary when no
  transcoder is specified.

* test-suite/tests/r6rs-ports.test: Remove superfluous global change of
  `%default-port-encoding' and accompanying comment.
  ("7.2.7 Input Ports"): Add test ensuring `open-file-input-port' opens
  a binary port when no transcoder is specified.
  ("8.2.10 Output ports"): Strengthen existing `open-file-output-port'
  binary-ness test by setting `%default-port-encoding' to "UTF-8".
2011-05-27 15:32:01 +02:00
Neil Jerram
153c4a4afa Emit a 1-based line number in error messages
* module/ice-9/boot-9.scm (exception-printers): Add 1 to the 0-based
  line number.
2011-05-26 17:58:18 +01:00
Neil Jerram
9228f9eb95 Reveal guile-tools's inner simplicity...
...by not using its own-rolled getopt, and moving the `list' function
to a separate script

* meta/guile-tools.in: Use (ice-9 getopt-long).

  (directory-files, strip-extensions, unique, find-submodules,
  list-scripts): Deleted (and moved to new `list.scm' file).

  (getopt): Deleted.

  (main): Use getopt-long.  Default to calling the `list' script if no
  script is specified.

* module/scripts/list.scm: New script.

* module/Makefile.am (SCRIPTS_SOURCES): Add list.scm.
2011-05-26 17:58:18 +01:00
Neil Jerram
6b4b4bfb09 Implement #:stop-at-first-non-option option for getopt-long
(For use by guile-tools)

* module/ice-9/getopt-long.scm: Use (ice-9 optargs) so we can use
  define*.

  (process-options): Add stop-at-first-non-option parameter.  When
  this is true, stop processing when we hit a non-option (so long as
  that non-option isn't something that resulted from the unclumping of
  a short option group).

  (getopt-long): Add #:stop-at-first-non-option keyword; pass it on to
  process-options.

* test-suite/tests/getopt-long.test ("stop-at-first-non-option"): New
  test (for the above).
2011-05-26 17:58:18 +01:00
Neil Jerram
0faf4b2a74 Handle short option unclumping progressively, instead of all upfront
This is needed as a prerequisite for the following change that
introduces the stop-at-first-non-option option, because when that
option is used we don't know upfront how far through the command
line we should proceed with unclumping.

* module/ice-9/getopt-long.scm (expand-clumped-singles): Delete.

  (process-options): Add a loop variable to indicate how many elements
  at the start of `argument-ls' are known not to be clumped.  When we
  see a short option and this variable is <= 0, perform unclumping
  (using code that used to be in expand-clumped-singles) and loop with
  the variable > 0.

  (getopt-long): Don't call expand-clumped-singles upfront here.
2011-05-26 17:58:18 +01:00
Neil Jerram
1e2cc0b630 Simplify getopt-long handling of option values, esp with multiple occurrences
Basically, accumulate values in the `process-options' loop variables,
instead of using set-option-spec-value!

* module/ice-9/getopt-long.scm (option-spec): Delete the `value' slot.

  (process-options): Delete `val!loop' and just use `loop' everywhere
  instead.  When adding an option spec to `found', add the
  corresponding value too; hence `found' becomes an alist, where it
  was previously a list of specs.

  (getopt-long): Use assq-ref to get values out of `found'.  Remove
  unhittable error condition for detecting an option that requires an
  explicit value, where a value wasn't supplied.  This condition is
  actually caught and handled in `process-options'.  Rewrite the end
  of the procedure much more simply.
2011-05-26 17:58:18 +01:00
Neil Jerram
ec7ea550f2 Fix "occurrances" typos in getopt-long code and test
* module/ice-9/getopt-long.scm (process-options, getopt-long): Change
  to "occurrences".

* test-suite/tests/getopt-long.test ("multiple occurrences"): Same
  again.
2011-05-26 17:58:18 +01:00
Andy Wingo
f4e45e91f2 lazily init futures worker pool
* module/ice-9/futures.scm (%workers, %create-workers!)
  (create-workers!): Define a mechanism to spawn off the future threads
  only when the first future is created.
  (make-future): Call create-workers! here.
2011-05-26 18:14:32 +02:00
Andy Wingo
ad4bd7c2c0 fix define-module ordering
* module/ice-9/boot-9.scm (define-module): Fix to load the #:use-module
  clauses in the order in which they appear in the define-module form.
  Thanks to Jan Nieuwenhuizen for the report.

* test-suite/standalone/test-import-order: Add new test that
  define-module and use-modules resolve the interface in the right
  order.

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-import-order-a.scm:
* test-suite/standalone/test-import-order-b.scm:
* test-suite/standalone/test-import-order-c.scm:
* test-suite/standalone/test-import-order-d.scm: Aux files.
2011-05-21 18:29:03 +02:00
Andy Wingo
0dd8493cb3 (syntax foo) -> #'foo in goops
* module/oop/goops.scm: Change instances of (syntax foo) to #'foo.
2011-05-21 13:13:58 +02:00
Andreas Rottmann
b6a66c21fc Improve R6RS conformance wrt. conditions in the I/O libraries
* module/rnrs/io/ports.scm (open-file-output-port): Handle `no-fail'
  file option.
  (with-i/o-filename-conditions): Use `with-throw-handler' instead of `catch'.
  (with-i/o-port-error,
  with-textual-output-conditions. with-textual-input-conditions): New
  exception-conversion helpers.
  (put-char, put-datum, put-string, display): Use
  `with-textual-output-conditions' instead of `with-i/o-encoding-error'
  to get proper conditions in case of write errors.
  (get-char, get-datum, get-line, get-string-all, lookahead-char):
  Likewise, for the input case.

* test-suite/tests/r6rs-ports.test (pass-if-condition, test-file,
  make-failing-port): New helpers.
  ("8.2.10 Output ports"): Add some tests for `open-file-output-port'.
  ("8.2.9 Textual Input"): Add tests read error conditions.
  ("8.2.12 Textual Output"): Add tests for write error conditions.
  ("8.3 Simple I/O"): Add tests for conditions, `call-with-input-file'
  and `call-with-output-file'.
2011-05-14 19:29:26 +02:00
Andy Wingo
d147fe2e68 all deprecated routines emit warnings
* module/ice-9/deprecated.scm (substring-move-left!)
  (substring-move-right!, dynamic-maybe-call, dynamic-maybe-link)
  (try-module-linked, try-module-dynamic-link)
  ($asinh, $acosh, $atanh, $sqrt, $abs, $exp, $log, $sin, $cos)
  ($tan, $asin, $acos, $atan, $sinh, $cosh, $tanh)
  (process-define-module): Add deprecation warnings.
2011-05-12 13:07:19 +02:00
Andy Wingo
8f6a4b248b fix some duplication in object tables
* module/language/glil/compile-assembly.scm (build-object-table): Don't
  add the same value to an object table twice.
2011-05-08 22:55:05 +02:00
Ludovic Courtès
19301dc56d Add `vhash-fold-right'.
* module/ice-9/vlist.scm (vhash-fold-right): New procedure.

* test-suite/tests/vlist.test ("vhash")["vhash-fold-right"]: New test.

* doc/ref/api-compound.texi (VHashes): Document `vhash-fold-right'.
2011-05-08 18:20:42 +02:00
Ludovic Courtès
bc00e06c7e Optimize `vlist-fold-right'.
* module/ice-9/vlist.scm (vlist-fold-right): Avoid `vlist-reverse' and
  instead `vlist-ref' individual elements.  The result is about twice
  faster.  Thanks Andy for suggesting it indirectly.  :-)
2011-05-08 18:20:42 +02:00
Andy Wingo
cb7523c26d compile-assembly: cleanup
* module/language/glil/compile-assembly.scm: Clean up code for
  subprograms (not needed, we just cache the glil) and object alists
  (replaced by constants tables).
2011-05-08 16:38:32 +02:00
Andy Wingo
f5695488b9 compile-assembly: use file-level constants table
* module/language/glil/compile-assembly.scm (compile-assembly): Rework
  to handle toplevel-specific code generation here, instead of in
  glil->assembly.  Specifically, here we build a global constant table,
  and arrange for it to be the objtable of the toplevel thunk.

  (compile-program): New helper, compiles a <glil-program> and returns
  just the (load-program ...) form.

  (compile-objtable): New helper, generates assembly to build an object
  table, using some other constants table, and possibly recursing to
  `compile-program' for cached GLIL programs.

  (glil->assembly): Simplify, removing the toplevel? argument, and
  replacing the object alist with an objtable computed in a previous
  pass.  Adapt to the new form of the objtable, and to use
  compile-program and compile-objtable.
2011-05-08 16:37:47 +02:00
Andy Wingo
7e7b8991b2 compile-assembly: add dump-constants, a new helper
* module/language/glil/compile-assembly.scm (dump-constants): New
  helper.  Generates bytecode that will result in a vector for the
  global object table being pushed on the stack.  The items in the
  global object table will share state as much as possible.
2011-05-08 16:31:18 +02:00
Andy Wingo
57b8eca691 compile-assembly: add build-constant-store, build-object-table
* module/language/glil/compile-assembly.scm (immediate?): New helper.
  (build-constant-store): New helper.  Walks the GLIL tree and builds up
  a constant table, as a vhash.
  (build-object-table): Another helper, builds a constant table for a
  given GLIL program.
2011-05-08 16:15:25 +02:00
Andy Wingo
6994fa9fef compile-assembly: make-meta refactor
* module/language/glil/compile-assembly.scm (make-meta): Avoid going
  through the compiler.
2011-05-08 16:13:41 +02:00
Andy Wingo
55fb5058a8 compile-assembly: add traversal helpers
* module/language/glil/compile-assembly.scm (vhash-fold-right2):
  (fold2, vector-fold2): Add some traversal helpers that we'll use in
  the next commit.
2011-05-08 16:09:22 +02:00
Andreas Rottmann
2252321bb7 Make the R6RS simple I/O library use conditions
* module/rnrs/io/ports.scm (display): Implement as an
  exception-converting wrapper around Guile's core display.
* module/rnrs/io/simple.scm: Don't export Guile's corresponding core
  procedures, but use `(rnrs io ports)' instead.  This way, we get the
  conditions required by R6RS raised.

* doc/ref/r6rs.texi (rnrs io simple): Mention that these procedures are
  supposed to raise R6RS conditions.
2011-05-07 23:48:46 +02:00
Andy Wingo
b706a01129 fix srfi-1 map-in-order definition
* module/srfi/srfi-1.scm (map-in-order): As we are not extending the
  core `map' binding, actually make a new `map-in-order' alias here.
  Fixes fresh builds.
2011-05-07 11:31:38 +02:00
Andy Wingo
a2230b653b map and for-each in scheme
* module/ice-9/boot-9.scm (map, for-each): Implement in Scheme instead
  of C.  There are boot versions before `cond' is defined.
  (map-in-order): Define this alias here instead of in evalext.h.

* libguile/eval.c: Stub out the map and for-each definitions to just
  call into Scheme.

* libguile/evalext.c: Remove map-in-order definition.

* module/srfi/srfi-1.scm: Replace all calls to map1 with calls to map.
  (map, for-each): Define implementations here, in Scheme, instead of in
  C.

* test-suite/tests/eval.test (exception:wrong-length, "map"): Update the
  expected exception for mapping over lists of different lengths.

* libguile/srfi-1.h:
* libguile/srfi-1.c: Remove map and for-each definitions.  Remove the
  bit that extended the core `map' primitive with another method: the
  right way to do that is with modules.
2011-05-05 23:07:37 +02:00
Andy Wingo
e2ccab571e psyntax simplification
* module/ice-9/psyntax.scm (strip): Inline the and-map* definition to
  its one call site.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-05-05 23:07:37 +02:00
Andy Wingo
9e775af3bf srfi-1 `member' in scheme, inlines to memq / memv in some cases
* libguile/srfi-1.c:
* libguile/srfi-1.h (scm_srfi1_member): Move implementation to Scheme.

* module/srfi/srfi-1.scm (member): Implement here, with the inlining
  cases for eq? and eqv?.  Speeds up a compiled bootstrap of
  psyntax.scm, because lset-adjoin inlines to the memq case.
  (lset<=): Reindent.

  (lset-adjoin, lset-union): If the comparator is eq? or eqv?, just pass
  it through to `member', so we inline to memq / memv.  Use something
  closer to the reference implementations.
2011-05-05 12:59:07 +02:00
Andy Wingo
89f9dd7065 speed up compile-bytecode
* module/language/assembly/compile-bytecode.scm (compile-bytecode):
  Rewrite to fill a bytevector directly, instead of using bytevector
  ports.  `write-bytecode' itself is still present and almost the same
  as before; it's just that `write-byte' et al now inline the effect of
  writing a byte to a binary port.

* test-suite/tests/asm-to-bytecode.test (comp-test): Refactor to use
  public interfaces.
2011-05-05 11:43:12 +02:00
Andy Wingo
81f529091b silly "optimization" in (language assembly)
* module/language/assembly.scm (byte-length): Silly, minor tweak: put
  the fixed-length instruction case first.  Seems to shave some 10% off
  the time compiling psyntax.scm (when the whole rest of the system is
  compiled, of course).
2011-05-05 11:43:12 +02:00
Andy Wingo
2d239a78d4 add gcprof
* module/statprof.scm (gcprof): New variant of statprof; instead of
  being driven by setitimer, this one is driven by the after-gc-hook.
2011-05-05 11:43:12 +02:00
Andy Wingo
e640b44046 minor statprof tweaks
* module/statprof.scm (statprof-reset): Make full-stacks? into an
  optional arg instead of doing the rest arg dance.
  (statprof-display): Format gc-time-taken appropriately.
2011-05-05 11:43:12 +02:00
Daniel Llorens
7ff0f239b2 Fix call-with-input-file & relatives for multiple values
* module/ice-9/r4rs.scm (call-with-input-file, call-with-output-file): Rewrite
  with call-with-values.
  (with-input-from-file): use call-with-input-file.
  (with-output-to-file, with-error-to-file): use call-with-output-file.
  Update docstrings to make clear that multiple values may be yielded.
2011-05-02 23:23:51 +02:00
Andy Wingo
8bee35bc53 (ice-9 poe) does not get handles from weak hash tables
* module/ice-9/poe.scm (pure-funcq, perfect-funcq): Reimplement to not
  use get-handle.
2011-05-01 23:01:13 +02:00
Andy Wingo
eceee4efe3 boot-9 fixme note
* module/ice-9/boot-9.scm (module-replace!): Add a fixme about using
  something other than object properties here.
2011-05-01 23:01:13 +02:00
Andy Wingo
b735d33b2b psyntax simplification
* module/ice-9/psyntax.scm (id-var-name): Just rely on multiple-values
  truncation.
2011-04-29 11:14:56 +02:00
Andy Wingo
e6efefad08 -x error message fix
* module/ice-9/command-line.scm (compile-shell-switches): Fix error
  message for -x switch.
2011-04-28 21:45:02 +02:00
Andy Wingo
dac9812a2e fix double-loading of script in -ds case
* module/ice-9/command-line.scm (compile-shell-switches): In the -ds
  case, we were erroneously loading the script twice.  Fix that.
2011-04-28 21:43:01 +02:00
Andy Wingo
91956a94fe allow while as an expression
* module/ice-9/boot-9.scm (while): Specify the return value as #f under
  normal conditions, #t under (break), and arg... under (break arg...).
* test-suite/tests/syntax.test ("while"): Test.
* doc/ref/api-control.texi (while do): Document.
2011-04-28 15:48:35 +02:00
Andy Wingo
18e444b40e add reset and shift
* module/ice-9/control.scm (reset, shift): Add implementations of these
  operators from Wolfgang J Moeller, derived from implementations by
  Oleg Kiselyov.
  (reset*, shift*): Procedural variants.

* test-suite/tests/control.test ("shift and reset"): Add tests,
  originally from Oleg Kiselyov.
2011-04-28 15:48:28 +02:00
Ludovic Courtès
756b1dfa6e Keep a 2.0.0-compatible `define-inlinable' macro in (srfi srfi-9).
Partially reverts 165b10ddfa and
531c9f1dc5.

* module/srfi/srfi-9.scm (define-inlinable): New macro.
2011-04-27 22:26:05 +02:00
Ludovic Courtès
94b55d3fa0 Gracefully handle `setlocale' errors at the REPL.
* module/ice-9/top-repl.scm (top-repl): Catch exceptions from
  `setlocale'.  Reported by CRLF0710 <crlf0710@gmail.com>.
2011-04-27 00:57:53 +02:00