bpt/guile.git
13 years agouse unbound fluids instead of `void' sentinel value
Brian Templeton [Sat, 14 Aug 2010 23:28:56 +0000 (19:28 -0400)]
use unbound fluids instead of `void' sentinel value

* module/language/elisp/compile-tree-il.scm (reference-with-check)
  (compile-without-void-checks, want-void-check?): Remove.

  (compile-function, compile-pair): Use `reference-variable' instead of
  `reference-with-check'.

  (compile-defvar): Only set `sym' if `sym' is not bound to a bound
  fluid, rather than requiring that its value be `void'.

  (process-options!): Remove `#:disable-void-check' option handling.

* module/language/elisp/runtime.scm (void)
  (reference-variable-with-check): Remove.

  (ensure-fluid!): Use an undefined fluid as the initial value for
  global variables.

* module/language/elisp/runtime/function-slot.scm (without-void-checks):
  Don't import or re-export.

* module/language/elisp/runtime/macros.scm (prog1, cond, or, dolist):
  Don't use `without-void-checks'.

* module/language/elisp/runtime/subrs.scm (symbol-value)
  (symbol-function, apply): Use `reference-variable' instead of
  `reference-variable-with-check'.

  (makunbound, fmakunbound, boundp, fboundp): Unset the variable's fluid
  (or the variable itself, if it isn't bound to a fluid).

* test-suite/tests/elisp-compiler.test ("Variable
  Setting/Referencing")["disabled void check (all)", "disabled void
  check (symbol list)", "without-void-checks"]: Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agofunction's argument can be a symbol
Brian Templeton [Thu, 22 Jul 2010 20:33:53 +0000 (16:33 -0400)]
function's argument can be a symbol

* module/language/elisp/compile-tree-il.scm (compile-function): the form
  `(function SYMBOL)' evaluates to the functional value of SYMBOL

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoallow `(setcar nil nil)' and `(setcdr nil nil)'
Brian Templeton [Thu, 22 Jul 2010 20:25:29 +0000 (16:25 -0400)]
allow `(setcar nil nil)' and `(setcdr nil nil)'

* module/language/elisp/runtime/subrs.scm (setcar, setcdr): Allow
  setting the car or cdr of `nil' to `nil'.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agosupport "#'" syntax for function expressions
Brian Templeton [Thu, 22 Jul 2010 19:12:50 +0000 (15:12 -0400)]
support "#'" syntax for function expressions

* module/language/elisp/lexer.scm (lex):
* module/language/elisp/parser.scm (get-expression): Support sharpsign
  single-quote syntax as an abbreviation for `function' expressions.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agosetq can take any number of arguments
Brian Templeton [Sat, 10 Jul 2010 06:47:16 +0000 (02:47 -0400)]
setq can take any number of arguments

* module/language/elisp/compile-tree-il.scm (compile-setq): Return nil
  if called with no arguments, and set the last variable to nil if its
  value is omitted.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agouse correct names for quasiquotation operators
Brian Templeton [Sat, 10 Jul 2010 00:33:32 +0000 (20:33 -0400)]
use correct names for quasiquotation operators

Use #{`}#, #{,}# and #{,@}# as the quasiquote, unquote and
unquote-splicing operators, respectively. Previously they were named
escaping.

* module/language/elisp/compile-tree-il.scm (unquote?): Change "\," to
  "#{,}#".
  (unquote-splicing): Change "\,@" to "#{,@}#".
  (#{compile-`}#): Rename from #{compile-\`}#.
* module/language/elisp/runtime/function-slot.scm: Import #{compile-`}#
  instead of #{compile-\`}#, and re-export as #{`}# instead of as
  #{\`}#.
* module/language/elisp/parser.scm (quotation-symbols):
* test-suite/tests/elisp-compiler.test ("Eval", "Quotation"):
* test-suite/tests/elisp-reader.test ("Parser"): Change "\`", "\,", and
  "\,@" to "#{`}#", "#{,}#" and "#{,@}#", respectively.

13 years agostore special operators in the function slot
Brian Templeton [Fri, 9 Jul 2010 23:52:48 +0000 (19:52 -0400)]
store special operators in the function slot

If the function slot of a symbol contains a pair with `special-operator'
in the car and a procedure in the cdr, the procedure is called to
compile the form to Tree-IL. This is similar to other Emacs Lisp
implementations, in which special operators are subrs.

* module/language/elisp/compile-tree-il.scm: Restructured to store
  special operator definitions in the function slot. Import `(language
  elisp runtime)' for `defspecial'. Export special operators so that
  `(language elisp runtime function-slot)' can re-export them.

  (backquote?): Removed; the backquote symbol is defined as a special
  operator, so it's no longer used in `compile-pair'.

  (is-macro?, get-macro): Replaced by `find-operator'.
  (find-operator): New procedure.

  (compile-progn, compile-if, compile-defconst, compile-defvar,
  compile-setq, compile-let, compile-lexical-let, compile-flet,
  compile-let*, compile-lexical-let*, compile-flet*,
  compile-without-void-checks, compile-with-always-lexical,
  compile-guile-ref, compile-guile-primitive, compile-while,
  compile-function, compile-defmacro, compile-defun, #{compile-`}#,
  compile-quote): New special operators with definitions taken from the
  pmatch form in `compile-pair'. There is no special operator `lambda';
  it is now a macro, as in other Elisp implementations.

  (compile-pair): Instead of directly compiling special forms, check for
  a special operator object in the function slot.

* module/language/elisp/runtime.scm: Export `defspecial'.
  (make-id): New function.
  (built-in-macro): Prefix macros with `macro-'.
  (defspecial): New syntax.

* module/language/elisp/runtime/function-slot.scm: Import and re-export
  special operators. Rename imported special operators and macros to
  remove prefixes. Re-export new macro `lambda'.

* module/language/elisp/runtime/macros.scm (macro-lambda): New Elisp
  macro.

13 years agoupdate elisp reader tests to handle EOF tokens
Brian Templeton [Fri, 2 Jul 2010 02:38:23 +0000 (22:38 -0400)]
update elisp reader tests to handle EOF tokens

* test-suite/tests/elisp-reader.test (lex-all, "end-of-input",
  "lexer/1"): Check for an EOF token instead of the symbol `*eoi*'.

13 years agomake user-defined macros available at runtime
Brian Templeton [Wed, 30 Jun 2010 20:54:45 +0000 (16:54 -0400)]
make user-defined macros available at runtime

* module/language/elisp/compile-tree-il.scm (ensuring-globals): New
  procedure.
  (define-macro!): Remove.
  (compile-pair) <defmacro>: Make macro available at runtime, not only
  during compilation.
  (compile-tree-il): Use `ensuring-globals'.

13 years agoallow fluid macro bindings
Brian Templeton [Wed, 30 Jun 2010 20:48:19 +0000 (16:48 -0400)]
allow fluid macro bindings

* module/language/elisp/compile-tree-il.scm (define-macro!, get-macro):
  Allow fluid macro bindings.

13 years agonew `load' subr
Brian Templeton [Wed, 30 Jun 2010 01:18:05 +0000 (21:18 -0400)]
new `load' subr

* module/language/elisp/runtime/subrs.scm: Define new subr `load'.
* module/language/elisp/runtime/function-slot.scm: Re-export `load'.

13 years agoIgnore #:warnings compiler option
Brian Templeton [Wed, 30 Jun 2010 01:13:18 +0000 (21:13 -0400)]
Ignore #:warnings compiler option

* module/language/elisp/compile-tree-il.scm (process-options!): Ignore
  #:warnings compiler option.

13 years agohandle EOF correctly in parser and lexer
Brian Templeton [Fri, 25 Jun 2010 03:03:08 +0000 (23:03 -0400)]
handle EOF correctly in parser and lexer

* module/language/elisp/lexer.scm (lex, get-lexer/1): Return a valid
  token at EOF.
* module/language/elisp/parser.scm (get-expression): Raise an error if
  EOF is reached.
  (read-elisp): If at EOF, return the EOF object instead of attempting
  to read an expression.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agostore macro definitions in the function slot
Brian Templeton [Wed, 23 Jun 2010 23:31:33 +0000 (19:31 -0400)]
store macro definitions in the function slot

Guile Emacs Lisp previously kept macros in a separate macro slot; now
macros are stored as macro objects in the function slot for
compatibility with other implementations.

* module/language/elisp/compile-tree-il.scm (macro-slot): Remove.
  (is-macro?): Check that the argument is a symbol. Now-unnecessary
  check removed in `compile-tree-il'.
  (macro?, define-macro!, get-macro): Store macro definitions in the
  function slot, not in a separate macro slot.
* module/language/elisp/runtime.scm (built-in-macro): Wrap the macro
  function in a macro object (i.e., cons the symbol `macro' onto it).
* module/language/elisp/runtime/function-slot.scm: Move contents to
  "subrs.scm". Re-export function and macro definitions instead of
  defining functions directly in this module.
* module/language/elisp/runtime/macro-slot.scm: Move contents to
  "macros.scm" and remove.
* module/language/elisp/runtime/macros.scm: New file containing macro
  definitions from "macro-slot.scm".
* module/language/elisp/runtime/subrs.scm: New file containing function
  definitions from "function-slot.scm".

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agouse existing bindings record for defmacro
Brian Templeton [Fri, 18 Jun 2010 00:25:42 +0000 (20:25 -0400)]
use existing bindings record for defmacro

* module/language/elisp/compile-tree-il.scm (compile-pair): Use existing
  bindings record during macro definition.

13 years agouse tree-il's support for optional arguments
Brian Templeton [Wed, 16 Jun 2010 21:18:30 +0000 (17:18 -0400)]
use tree-il's support for optional arguments

* module/language/elisp/compile-tree-il.scm (compile-lambda): Use
  Tree-IL's support for optional arguments.
  (process-optionals, process-rest): Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agomake `pass-if-equal' literal in `compile-test'
Brian Templeton [Wed, 23 Jun 2010 23:40:03 +0000 (19:40 -0400)]
make `pass-if-equal' literal in `compile-test'

* test-suite/tests/elisp-compiler.test (compile-test): Add
  `pass-if-equal' to the list of literal identifiers

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoreindent
Brian Templeton [Mon, 7 Jun 2010 20:38:23 +0000 (16:38 -0400)]
reindent

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/spec.scm: Reindent.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoreformat comments
Brian Templeton [Mon, 7 Jun 2010 20:38:00 +0000 (16:38 -0400)]
reformat comments

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/runtime/value-slot.scm: Reformat comments.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agowhitespace changes
Brian Templeton [Mon, 7 Jun 2010 20:37:24 +0000 (16:37 -0400)]
whitespace changes

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm: Ensure that all
  top-level forms and comments are separated by exactly one newline.
  Remove blank lines in most procedure bodies. Delete trailing
  whitespace.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoautoload compile-file in (guile-user)
Brian Templeton [Wed, 14 Jul 2010 21:47:37 +0000 (17:47 -0400)]
autoload compile-file in (guile-user)

* module/ice-9/boot-9.scm (guile-user): Autoload `compile-file'.

13 years agovariable-unset!
Brian Templeton [Sat, 14 Aug 2010 23:00:20 +0000 (19:00 -0400)]
variable-unset!

* libguile/variable.c (scm_variable_unset_x): New function.
* libguile/variable.h (scm_variable_unset_x): New prototype.

13 years agounbound fluids
Brian Templeton [Sat, 14 Aug 2010 22:35:17 +0000 (18:35 -0400)]
unbound fluids

* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New functions.

  (fluid_ref): New function; like scm_fluid_ref, but will not throw an
  error for unbound fluids.
  (scm_fluid_ref, swap_fluid): Use `fluid_ref'.

* libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New prototypes.

* libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to
  `vm_error_unbound_fluid'.
* libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error
  message.

* test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound
  fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound
  fluid", "unbound fluids can be set", "bound fluids can be unset"]: New
  tests.

13 years agobetter unbound variable errors in the vm
Andy Wingo [Tue, 7 Dec 2010 11:26:07 +0000 (12:26 +0100)]
better unbound variable errors in the vm

* libguile/vm-i-system.c (variable-ref, toplevel-ref)
  (long-toplevel-ref): Fixup callers.

* libguile/vm-engine.c (vm_error_unbound): Don't use vm-error for
  unbound vars, use misc-error. Don't include VM: in the string. Take
  the name directly in finish_args, not as a list.

13 years agomake guile-test work without configuration
Brian Templeton [Wed, 14 Jul 2010 00:55:45 +0000 (20:55 -0400)]
make guile-test work without configuration

* test-suite/guile-test: Use "../meta/guile" as the interpreter instead
  of "../libguile/guile".
  (default-test-suite): New function, replacing the variable of the same
  name. Look for tests in the same directory as the guile-test script.
  Throw an error if not invoked as `guile-test'.
  (test-suite): The old default value of `default-test-suite' could now
  throw an error, and this already gets initialized in `main', so don't
  provide an initial value.

13 years agoPut `figures' into standard texinfo form
Neil Jerram [Mon, 6 Dec 2010 23:02:12 +0000 (23:02 +0000)]
Put `figures' into standard texinfo form

* doc/ref/goops.texi (Example, Inheritance): Remove unnecessary figure
  references.  Use @float and @ref.
  (Class precedence list): Ditto.

13 years agoMerge `tutorial' and `reference' treatments of the same basic GOOPS
Neil Jerram [Mon, 6 Dec 2010 22:28:39 +0000 (22:28 +0000)]
Merge `tutorial' and `reference' treatments of the same basic GOOPS
material

* doc/ref/goops.texi (GOOPS): Move use of (oop goops) here.

  (Class Definition): Merged with `Defining New Classes'

  (Instance Creation): Insert before covering slot options.  Merge in
  material from `Creating Instances'.

  (Slot Options): Merged some better wording and index entries from
  the tutorial version.

  (Slot Description Example): New node, containing the <my-complex>
  material from the tutorial.

  (Methods and Generic Functions, Inheritance): Tutorial sections
  moved into main line of the manual.

* doc/ref/goops-tutorial.texi: Nothing left here now.

13 years agoMinor textual markups
Neil Jerram [Mon, 6 Dec 2010 20:24:58 +0000 (20:24 +0000)]
Minor textual markups

* doc/ref/goops-tutorial.texi (Class definition): No reason to assume
  particular familiarity with CLOS.
  (Instance creation and slot access): Remove a couple of words.

13 years agoscm_setvbuf doesn't throw away current buffers
Andy Wingo [Mon, 6 Dec 2010 18:59:15 +0000 (19:59 +0100)]
scm_setvbuf doesn't throw away current buffers

* libguile/ports.c (scm_drain_input): Slight optimization.

* libguile/fports.c (scm_setvbuf): If there is buffered output, flush
  it.  If there is input, drain it, and then unread it after updating
  the buffers.  Much more sensible than dropping it silently...

13 years agohttp-read calls setvbuf only once
Andy Wingo [Mon, 6 Dec 2010 18:52:51 +0000 (19:52 +0100)]
http-read calls setvbuf only once

* module/web/server/http.scm (http-read): Don't play the setvbuf dance,
  it was throwing away buffered input. Instead just call setvbuf once
  before doing any reads or writes.

13 years agoice-9 poll handles buffered io too
Andy Wingo [Mon, 6 Dec 2010 18:27:22 +0000 (19:27 +0100)]
ice-9 poll handles buffered io too

* libguile/poll.c (scm_primitive_poll): Account for buffered I/O.

* module/ice-9/poll.scm (poll): Adapt to call primitive-poll with the
  port vector too.

13 years agofix name...
Andy Wingo [Mon, 6 Dec 2010 14:32:13 +0000 (15:32 +0100)]
fix name...

* module/web/request.scm (read-request-body/latin-1): Fix name...

13 years agofix read-{request,response}-body/latin-1
Andy Wingo [Mon, 6 Dec 2010 14:30:45 +0000 (15:30 +0100)]
fix read-{request,response}-body/latin-1

* module/web/request.scm (read-response-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Avoid the
  craziness of the read-delimited! interface and hand-roll our
  own. Fixes errors if read-delimited returns #f or EOF.

13 years agoupdate read-delimited! docs
Andy Wingo [Mon, 6 Dec 2010 14:19:40 +0000 (15:19 +0100)]
update read-delimited! docs

* doc/ref/api-io.texi (Line/Delimited): Update the read-delimited!
  docs.

13 years agoleniency regarding quality values in http.scm
Andy Wingo [Mon, 6 Dec 2010 12:52:56 +0000 (13:52 +0100)]
leniency regarding quality values in http.scm

* module/web/http.scm: Add commentary.
  (parse-quality): Allow .NNN to be interpreted as 0.NNN.

* test-suite/tests/web-http.test ("request headers"): Add a test.

13 years agofix entity tag writing
Andy Wingo [Mon, 6 Dec 2010 11:58:16 +0000 (12:58 +0100)]
fix entity tag writing

* module/web/http.scm (write-entity-tag): Fix writing of entity tags
  (strong versus weak).

13 years agomore robustness in http-read
Andy Wingo [Mon, 6 Dec 2010 10:24:48 +0000 (11:24 +0100)]
more robustness in http-read

* module/web/server/http.scm (http-read): If there was an error reading
  the request, be sure to close the request port.

13 years agohttp doesn't keep-alive requests for which there was an error
Andy Wingo [Sun, 5 Dec 2010 19:24:14 +0000 (20:24 +0100)]
http doesn't keep-alive requests for which there was an error

* module/web/server/http.scm (keep-alive?): Don't keep the client around
  if there is an error.

13 years ago(web server http) comment
Andy Wingo [Sat, 4 Dec 2010 18:45:51 +0000 (19:45 +0100)]
(web server http) comment

* module/web/server/http.scm: Add comment about charsets.

13 years agofix error handling in read-{request,response}-body/latin-1
Andy Wingo [Sat, 4 Dec 2010 18:45:09 +0000 (19:45 +0100)]
fix error handling in read-{request,response}-body/latin-1

* module/web/request.scm (read-request-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Detect short
  reads instead of returning a full buffer with the last bits zeroed
  out. (Before the make-string commit, they contained uninitialized
  memory, which was a fairly serious error.)

13 years agomake-string et al nulls memory if not given an initializer
Andy Wingo [Sat, 4 Dec 2010 18:31:20 +0000 (19:31 +0100)]
make-string et al nulls memory if not given an initializer

* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the
  memory block, so users need to make sure it is initialized.

* libguile/bitvectors.c (scm_c_make_bitvector):
* libguile/bytevectors.c (scm_make_bytevector):
* libguile/strings.c (scm_c_make_string): If no initializer is given,
  initialize the bytes to 0. Prevents information leakage if an app uses
  make-string et al without initializers.

* libguile/foreign.c (make_cif): Initialize this too, to prevent leakage
  in the struct holes. Paranoia...

13 years agoread-delimited is clearer and conses less
Andy Wingo [Fri, 3 Dec 2010 17:03:51 +0000 (18:03 +0100)]
read-delimited is clearer and conses less

* module/ice-9/rdelim.scm (read-delimited): Clarify and somewhat
  optimize implementation.

13 years agohttp server impl reads body as a bytevector by default
Andy Wingo [Fri, 3 Dec 2010 16:37:22 +0000 (17:37 +0100)]
http server impl reads body as a bytevector by default

* module/web/server/http.scm (http-read): Read body as a bytevector by
  default. That way we punt encoding issues to the app.

13 years agoremove redundant error-handling block
Andy Wingo [Fri, 3 Dec 2010 15:41:46 +0000 (16:41 +0100)]
remove redundant error-handling block

* module/web/server/http.scm (http-read): No need for a
  call-with-error-handling block here, as the read impl is itself within
  an error-handling block.

13 years agoweb server micro-tuning
Andy Wingo [Fri, 3 Dec 2010 15:30:52 +0000 (16:30 +0100)]
web server micro-tuning

* module/web/server/http.scm (http-open): Allow up to 128 pending
  connections -- the default value for somaxconn on a number of
  machines. This is from the HOP paper.
  (http-read): Set the send buffer to 12 KB, also from the HOP paper.

13 years agoreverse order of poll-set traversal in http-read
Andy Wingo [Fri, 3 Dec 2010 15:11:37 +0000 (16:11 +0100)]
reverse order of poll-set traversal in http-read

* module/web/server/http.scm (http-read): Rewrite to iterate down the
  pollset, so the vector shuffles touch less memory and the end
  condition of the loop is clearer.

13 years ago(web server) punts keep-alive to impls; http server uses (ice-9 poll)
Andy Wingo [Fri, 3 Dec 2010 14:31:57 +0000 (15:31 +0100)]
(web server) punts keep-alive to impls; http server uses (ice-9 poll)

* module/web/server.scm: Rewrite to remove the extra "keep-alive"
  parameter. Instead, since the server is an essentially stateful
  object, have clients that want to do keep-alive manage that set as
  part of the server state. Also avoids imposing a particular data
  structure on the server implementation.

* module/web/server/http.scm: Adapt to the new server interface. Also,
  use a poll set instead of select and lists. Makes handling 1000
  clients at a time much more possible.

13 years agoASYNC_TICK after catching EINTR in SCM_SYSCALL
Andy Wingo [Fri, 3 Dec 2010 14:17:35 +0000 (15:17 +0100)]
ASYNC_TICK after catching EINTR in SCM_SYSCALL

* libguile/_scm.h (SCM_SYSCALL): As in scm_syserror, do a SCM_ASYNC_TICK
  before resuming the syscall after an EINTR.

13 years agoadd (ice-9 poll), a poll wrapper
Andy Wingo [Fri, 3 Dec 2010 12:09:43 +0000 (13:09 +0100)]
add (ice-9 poll), a poll wrapper

* libguile/poll.c:
* libguile/poll.h:
* module/ice-9/poll.scm: New module, (ice-9 poll).

* module/Makefile.am:
* libguile/init.c:
* libguile/Makefile.am: Adapt.

* configure.ac: Check for poll.h and poll.

13 years agoAdd `(ice-9 futures)'.
Ludovic Courtès [Thu, 2 Dec 2010 23:35:15 +0000 (00:35 +0100)]
Add `(ice-9 futures)'.

* doc/ref/api-scheduling.texi (Threads): Add short introduction.
  Mention the `threads' feature.  Add cross-reference to futures.
  (Futures): New node.

* module/Makefile.am (ICE_9_SOURCES): Add `ice-9/futures.scm'.

* module/ice-9/futures.scm: New file.

* test-suite/Makefile.am (SCM_TESTS): Add `tests/future.test'.

* test-suite/tests/future.test: New file.

13 years agoAdd bindings to GNU `sched_setaffinity' and `sched_getaffinity'.
Ludovic Courtès [Wed, 1 Dec 2010 22:58:39 +0000 (23:58 +0100)]
Add bindings to GNU `sched_setaffinity' and `sched_getaffinity'.

* configure.ac: Add checks for `sched_setaffinity' and
  `sched_getaffinity'.

* doc/ref/posix.texi (Processes): Document `getaffinity' and
  `setaffinity'.

* libguile/posix.c (cpu_set_to_bitvector,
  scm_getaffinity)[HAVE_SCHED_GETAFFINITY]: New functions.
  (scm_setaffinity)[HAVE_SCHED_SETAFFINITY]: New function.

* libguile/posix.h (scm_getaffinity, scm_setaffinity): New declarations.

* test-suite/tests/posix.test ("affinity"): New test prefix.

13 years agono need for fport_fill_input to select() before read()
Andy Wingo [Thu, 2 Dec 2010 22:41:00 +0000 (23:41 +0100)]
no need for fport_fill_input to select() before read()

* libguile/fports.c (fport_fill_input): Likewise to the previous commit,
  no need to select() before read().

13 years agoscm_accept no longer leaves guile mode
Andy Wingo [Thu, 2 Dec 2010 22:24:39 +0000 (23:24 +0100)]
scm_accept no longer leaves guile mode

* libguile/socket.c (scm_accept): Revert
  7d1fc8721724ab64ccdc44d6f4f84abad43751b4. Now that we don't need to
  leave guile mode in order for GC to happen, don't do so, as we assume
  that anyone who cares has already done a select() beforehand.

13 years agosxml->xml fix
Andy Wingo [Thu, 2 Dec 2010 21:24:26 +0000 (22:24 +0100)]
sxml->xml fix

* module/sxml/simple.scm (attribute-value->xml): Whoops, fix null case.

13 years agosxml->xml writes directly to a port
Andy Wingo [Thu, 2 Dec 2010 16:25:46 +0000 (17:25 +0100)]
sxml->xml writes directly to a port

* module/sxml/simple.scm: Remove "universal-sxslt-rules" -- it was a bad
  interface, and I couldn't find any users of it.
  (sxml->xml): Rewrite so that instead of generating another tree of
  data, we write the data directly to a port.

13 years agoadd some debugging to (web server)
Andy Wingo [Thu, 2 Dec 2010 12:36:04 +0000 (13:36 +0100)]
add some debugging to (web server)

* module/web/server.scm: Add some basic elapsed-time debugging, but only
  if you flip a switch to turn it on at expand-time.

13 years agobetter socket buffering on http web server backend
Andy Wingo [Thu, 2 Dec 2010 12:33:49 +0000 (13:33 +0100)]
better socket buffering on http web server backend

* module/web/server/http.scm (http-read, http-write): Line-buffer the
  port while we're reading the request, and block-buffer it otherwise
  Use the default block size.

13 years agoindentation fix in ports.c
Andy Wingo [Thu, 2 Dec 2010 11:46:15 +0000 (12:46 +0100)]
indentation fix in ports.c

* libguile/ports.c (scm_i_get_conversion_strategy): Indentation fix.

13 years ago(web server) supports non-utf-8 charsets
Andy Wingo [Thu, 2 Dec 2010 11:28:35 +0000 (12:28 +0100)]
(web server) supports non-utf-8 charsets

* module/web/server.scm (sanitize-response): Support charsets other than
  utf-8. Oddly collecting a string and converting it to utf-8 appears to
  be faster than collecting a utf-8 bytevector directly.

13 years agoadd simple web app examples
Andy Wingo [Thu, 2 Dec 2010 10:47:19 +0000 (11:47 +0100)]
add simple web app examples

* examples/web/hello.scm:
* examples/web/debug-sxml.scm: New examples, for simple web
  applications.

* examples/README:
* examples/Makefile.am: Add new files.

13 years agohttp web server impl ignores SIGPIPE
Andy Wingo [Mon, 29 Nov 2010 12:00:43 +0000 (13:00 +0100)]
http web server impl ignores SIGPIPE

* module/web/server/http.scm (http-open): Ignore SIGPIPE. Keeps the
  server from dying in some circumstances.

13 years agostub fixes to http 1.0 support in the web server
Andy Wingo [Mon, 29 Nov 2010 11:05:57 +0000 (12:05 +0100)]
stub fixes to http 1.0 support in the web server

* module/web/server.scm (read-client): Fix number of returned values in
  the case in which there is an error reading the client.
  (sanitize-response): Add a case to adapt the reponse to the request
  version.
  (handle-request): Sanitize the response within an error-handling
  block.
  (serve-one-client): Move sanitation out of here.

* module/web/server/http.scm (keep-alive?): A more proper detection on
  whether we should support persistent connections.

* module/web/response.scm (adapt-response-version): New routine, to
  adapt a response to a given version. Currently a stub.

13 years agoSome tweaks to the R6RS support
Andreas Rottmann [Thu, 25 Nov 2010 22:03:12 +0000 (23:03 +0100)]
Some tweaks to the R6RS support

* module/rnrs/base.scm (error, assert): Define -- they were missing.
  (assertion-violation): Properly treat a #f `who' argument.

* module/rnrs/conditions.scm (condition): Use `assertion-violation'
  instead of the undefined `raise'.
  (define-condition-type): Fix for multiple fields.
* test-suite/tests/r6rs-conditions.test: Test accessors of a
  multiple-field condition.  Also import `(rnrs base)' to allow
  stand-alone running of the tests; apparently the `@' references
  scattered throughout the R6RS modules make the libraries sensitive to
  their load order -- for instance, trying to load `(rnrs conditions)'
  before `(rnrs base)' is loaded fails.

* module/rnrs/records/inspection.scm: Use `assertion-violation' instead
  of an explicit `raise'.
* module/rnrs/records/syntactic.scm (process-fields): Use
  `syntax-violation' instead of bogus invocations of `error'.

13 years agoFix `regexp.test' when the "en_US.utf8" locale isn't available.
Ludovic Courtès [Wed, 24 Nov 2010 22:38:01 +0000 (23:38 +0100)]
Fix `regexp.test' when the "en_US.utf8" locale isn't available.

* test-suite/tests/regexp.test ("nonascii locales"): Move `with-locale'
  within the body of `pass-if' so that `unresolved' is caught.

13 years agoHonor R6RS transcoder error handling modes, when possible.
Ludovic Courtès [Wed, 24 Nov 2010 22:01:50 +0000 (23:01 +0100)]
Honor R6RS transcoder error handling modes, when possible.

* module/rnrs/io/ports.scm (transcoded-port): Change RESULT's conversion
  strategy based on TRANSCODER's error-handling mode.

* test-suite/tests/r6rs-ports.test ("8.2.6  Input and output
  ports")["transcoded-port [error handling mode = raise]",
  "transcoded-port [error handling mode = replace]"]: New tests.

13 years agoAdd implementation of "transcoded ports"
Andreas Rottmann [Sun, 21 Nov 2010 22:17:54 +0000 (23:17 +0100)]
Add implementation of "transcoded ports"

* libguile/r6rs-ports.c (make_tp, tp_write, tp_fill_input, tp_flush)
  (tp_close, initialize_transcoded_ports, scm_i_make_transcoded_port): New
  functions.
  (scm_init_r6rs_ports): Call `initialize_transcoded_ports'.
* module/rnrs/ports.scm (transcoded-port): Actually implement,
  using `%make-transcoded-port'.
* test-suite/tests/r6rs-ports.test ("8.2.6 Input and output ports"): Added a
  few tests for `transcoded-port'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoWork towards a more complete implementation of `(rnrs io ports)'
Andreas Rottmann [Sun, 21 Nov 2010 22:17:53 +0000 (23:17 +0100)]
Work towards a more complete implementation of `(rnrs io ports)'

* module/rnrs/io/ports.scm: (file-options, buffer-mode, eol-style)
  (error-handling-mode, make-transcoder, native-transcoder)
  (latin-1-codec, utf-8-codec, utf-16-codec)
  (call-with-bytevector-output-port, open-file-input-port)
  (open-file-output-port, make-custom-textual-output-port)
  (flush-output-port, put-char, put-datum, put-string, get-char)
  (get-datum, get-line, get-string-all, lookahead-char)
  (standard-input-port, standard-output-port, standard-error-port):
  Define all of these.

  (call-with-port): Don't use `dynamic-wind', as it is against its
  specification in R6RS 8.2.6.

* module/rnrs.scm: Export procedures added.

* module/rnrs/io/simple.scm (call-with-input-file)
  (call-with-output-file): Define these in terms of R6RS procedures to
  get correct exception behavior.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoReorganize the R6RS I/O condition types
Andreas Rottmann [Sun, 21 Nov 2010 22:17:52 +0000 (23:17 +0100)]
Reorganize the R6RS I/O condition types

Move the I/O condition types from `(rnrs conditions)', where they were
not exported, to `(rnrs files)', where they are.

* module/rnrs/conditions.scm: Remove definition of I/O condition types.
* module/rnrs/files.scm: Replace references to I/O condition types
  inside `(rnrs conditions)' with the actual definitions.
* module/rnrs/io/simple.scm: Don't `@@'-reference the I/O condition types, just
  imported them from `(rnrs files)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoTurn `(rnrs io ports)' into an R6RS library
Andreas Rottmann [Sun, 21 Nov 2010 22:17:51 +0000 (23:17 +0100)]
Turn `(rnrs io ports)' into an R6RS library

* module/rnrs/io/ports.scm: Change into an R6RS library from a "regular"
  Guile module, so the bookkeeping for #:re-export and #:replace is done
  automatically and we gain control over the imports from `(guile)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agofix regexp matches to refer to chars, not bytes
Andy Wingo [Tue, 23 Nov 2010 21:39:06 +0000 (22:39 +0100)]
fix regexp matches to refer to chars, not bytes

* libguile/regex-posix.c (fixup_multibyte_match): Fixup the match
  structure to refer to character offsets, not byte offsets. Fixes bug
  31650.

* test-suite/tests/regexp.test: Add a test.

13 years agofix web server bugs
Andy Wingo [Tue, 23 Nov 2010 15:02:21 +0000 (16:02 +0100)]
fix web server bugs

* module/web/http.scm (valid-quality?):
* module/web/server.scm (sanitize-response): Fix a couple bugs.

13 years agofix up a couple content-length issues in web/server.scm:sanitize-response
Andy Wingo [Mon, 22 Nov 2010 22:58:24 +0000 (23:58 +0100)]
fix up a couple content-length issues in web/server.scm:sanitize-response

* module/web/server.scm (sanitize-response): Allow body to be #f. Don't
  require or insert a content-length if there is no body.

13 years agoEnumeration set universe comparisons should be done with `equal?'
Julian Graham [Sun, 21 Nov 2010 20:35:44 +0000 (15:35 -0500)]
Enumeration set universe comparisons should be done with `equal?'

* module/rnrs/enums.scm (enum-set-union, enum-set-intersection,
  enum-set-difference): Compare enum-set universes with `equal?' to support
  sets generated using constructor syntax bound by `define-enumeration'.
* test-suite/tests/r6rs-enums.test (enum-set-union, enum-set-intersection,
  enum-set-difference): New test cases for syntactically-generated sets.

13 years agoFix missing port-table locking and bytevector output port segfault
Andreas Rottmann [Sat, 20 Nov 2010 17:40:30 +0000 (18:40 +0100)]
Fix missing port-table locking and bytevector output port segfault

* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop): Lock
  the port table.

* libguile/r6rs-ports.c (make_bop): Let the returned extraction
  procedure refer to the port's buffer instead of the port itself.  This
  fixes a segfault if the port is closed before the extraction procedure
  is called.
  (bop_proc_apply): Adapt accordingly.
* test-suite/tests/r6rs-ports.test (8.2.10 Output ports): Add testcase
  for extraction after close.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoAllow user-defined meta-commands
Andreas Rottmann [Sat, 20 Nov 2010 22:14:05 +0000 (23:14 +0100)]
Allow user-defined meta-commands

Besides allowing user-defined meta-commands, this change also refactors
the meta-command machinery to split reading a command's arguments from
the procedure actually implementing it, and hence allows nesting
meta-commands.  As an example of such a command, ",in" is added as a new
meta-command.

* module/system/repl/command.scm: Export `define-meta-command'.
  (*command-module*): Replaced by the hash table `*command-infos*'.
  (command-info, make-command-info, command-info-procedure)
  (command-info-arguments-reader): New procedures, encapsulating the
  information about a meta-command.
  (command-procedure): Adapted to use the `command-info' lookup
  procedure.
  (read-command-arguments): New auxiliary procedure invoking a command's
  argument reader procedure.
  (meta-command): Adapted to the split of reading arguments and
  executing a command.
  (add-meta-command!): New auxiliary procedure, registers a meta
  command's procedure and argument reader into `*command-infos* and
  `*command-table*.
  (define-meta-command): Extended to allow specification of the command's
  category; split the argument reader and actual command procedure.
  (guile:apropos, guile:load, guile:compile-file, guile:gc): Remove these
  aliases, they are unnecessary as we now use a hash table instead of the
  module to store the commands.
  (in): New meta-command, which evaluates an expression, or alternatively
  executes another meta-command, in the context of a specific module.
* doc/ref/scheme-using.texi (Module Commands): Document the `in'
  meta-command.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoannounce flex version in autogen.sh
Andy Wingo [Sat, 20 Nov 2010 22:18:43 +0000 (23:18 +0100)]
announce flex version in autogen.sh

* autogen.sh: Announce flex version. Has the side-effect of checking for
  flex when building from git.

13 years agoAllow specifying load extensions on the command line
Andreas Rottmann [Sat, 20 Nov 2010 00:05:10 +0000 (01:05 +0100)]
Allow specifying load extensions on the command line

Add a new command-line switch `-x', which manipulates the
%load-extensions list.

* libguile/script.c (scm_compile_shell_switches): Process the new "-x"
  switch.
  (scm_shell_usage): Mention the "-x" switch.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add "-x" switch to the
  list of command-line switches.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoUse `define-module*' in (ice-9 history).
Ludovic Courtès [Fri, 19 Nov 2010 23:47:12 +0000 (00:47 +0100)]
Use `define-module*' in (ice-9 history).

* module/ice-9/history.scm: Use `define-module*' instead of
  `process-define-module'.

13 years agobump objcode version
Andy Wingo [Fri, 19 Nov 2010 16:51:16 +0000 (17:51 +0100)]
bump objcode version

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the
  process-define-module deprecation means that outside compiled code
  won't find process-define-module in the (guile) module, as they would
  before.

13 years agofix string-filter and string-delete argument order
Andy Wingo [Fri, 19 Nov 2010 16:08:36 +0000 (17:08 +0100)]
fix string-filter and string-delete argument order

* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
  char_pred and s argument order, to comply with SRFI-13. There is a
  back-compat shim that will detect programs that used the old,
  erroneous interface, while giving a warning.

* doc/ref/api-data.texi: Update docs.

13 years agodeprecate process-define-module
Andy Wingo [Fri, 19 Nov 2010 14:08:07 +0000 (15:08 +0100)]
deprecate process-define-module

* module/ice-9/boot-9.scm:
* module/ice-9/deprecated.scm (process-define-module): Deprecate.

13 years agodefine-module compiles to define-module*
Andy Wingo [Fri, 19 Nov 2010 13:43:31 +0000 (14:43 +0100)]
define-module compiles to define-module*

* module/ice-9/boot-9.scm (define-module): Compile down to a call to
  define-module*, not process-define-module.

13 years agoscm_c_define_module uses define-module*
Andy Wingo [Fri, 19 Nov 2010 12:11:47 +0000 (13:11 +0100)]
scm_c_define_module uses define-module*

* libguile/modules.c (scm_c_define_module):
* module/ice-9/boot-9.scm: Update to have the C function call
  define-module*.

13 years agomake module definition procedure more structured
Andy Wingo [Fri, 19 Nov 2010 12:06:03 +0000 (13:06 +0100)]
make module definition procedure more structured

* module/ice-9/boot-9.scm (define-module*): New procedure, like
  process-define-modules but more structured.
  (process-define-module): Reimplement in terms of define-module*.

13 years agorelax sizeof(long) restriction in configure.ac
Andy Wingo [Fri, 19 Nov 2010 10:39:06 +0000 (11:39 +0100)]
relax sizeof(long) restriction in configure.ac

* configure.ac: Relax the sizeof(long)==sizeof(void*) restriction,
  instead asserting that the sizeof(long)<=sizeof(void*). There will
  still be problems on nonstandard platforms related to the interface
  with gmp, but those are confined to numbers.c.

13 years agofix a number of assuptions that a long could hold an inum
Andy Wingo [Fri, 19 Nov 2010 10:29:26 +0000 (11:29 +0100)]
fix a number of assuptions that a long could hold an inum

* libguile/bytevectors.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/numbers.c:
* libguile/random.c:
* libguile/read.c:
* libguile/vm-i-scheme.c: Fix a number of assumptions that a long could
  hold an inum. This is not the case on platforms whose void* is larger
  than their long.

* libguile/numbers.c (scm_i_inum2big): New helper, only implemented for
  sizeof(void*) == sizeof(long); produces a compile error on other
  platforms. Basically gmp doesn't have a nice interface for converting
  between mpz values and intmax_t.

13 years agosimpos tweak
Andy Wingo [Thu, 18 Nov 2010 21:31:34 +0000 (22:31 +0100)]
simpos tweak

* libguile/simpos.c (scm_system_star): Use scm_from_ulong, as we do cast
  to ulong.

13 years agofix a number of assumptions that a pointer could fit into a long
Andy Wingo [Thu, 18 Nov 2010 21:30:27 +0000 (22:30 +0100)]
fix a number of assumptions that a pointer could fit into a long

* libguile/debug.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/objcodes.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/struct.c:
* libguile/vm.c: Fix a number of instances in which we assumed we could
  fit a pointer into a long.

13 years agoFix incorrect uses of en-dashes and em-dashes in the intro.
Ludovic Courtès [Fri, 19 Nov 2010 13:28:40 +0000 (14:28 +0100)]
Fix incorrect uses of en-dashes and em-dashes in the intro.

* doc/ref/intro.texi (Introduction): Use commas instead of en-dashes
  around "for example".  Use em-dashes instead of en-dashes around
  parenthetical phrases.  Remove spaces around em-dashes.

13 years agoInclude <alloca.h> wherever `alloca' is used.
Ludovic Courtès [Fri, 19 Nov 2010 13:14:53 +0000 (14:14 +0100)]
Include <alloca.h> wherever `alloca' is used.

Patch provided by <carlo.bramix@libero.it> (tiny change).

* libguile/control.c, libguile/fluids.c, libguile/foreign.c,
  libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.

13 years agoOptimize fixnum comparison.
Ludovic Courtès [Fri, 19 Nov 2010 10:18:42 +0000 (11:18 +0100)]
Optimize fixnum comparison.

* libguile/vm-i-scheme.c (REL): Don't untag X and Y since tagging
  preserves ordering.

13 years agoAdd fixnum arithmetic benchmarks.
Ludovic Courtès [Fri, 19 Nov 2010 10:06:10 +0000 (11:06 +0100)]
Add fixnum arithmetic benchmarks.

* benchmark-suite/benchmarks/arithmetic.bm ("fixnum")["*", "/"]: New
  benchmarks.

13 years agoAdd optimized tagged integer addition/subtractions for x86_64.
Ludovic Courtès [Wed, 17 Nov 2010 22:06:26 +0000 (23:06 +0100)]
Add optimized tagged integer addition/subtractions for x86_64.

This results in a 17% improvement in the execution time of the "+" and
"-" benchmarks for fixnums.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB)[defined __x86_64__ &&
  SCM_GNUC_PREREQ (4, 5)]: New macros.
  (add)[defined ASM_ADD]: Use `ASM_ADD' for the fast path.
  (sub)[defined ASM_SUB]: Use `ASM_SUB' for the fast path.

* test-suite/tests/numbers.test ("+")["fixnum + fixnum = bignum
  (32-bit)", "fixnum + fixnum = bignum (64-bit)", "bignum + fixnum =
  fixnum", "wrong type"]: New tests.
  ("-")["fixnum - fixnum = bignum (32-bit)", "fixnum - fixnum = bignum
  (64-bit)", "bignum - fixnum = fixnum", "wrong type"]: New tests.

* test-suite/tests/00-initial-env.test ("goopsless")["+ wrong type
  argument"]: Use `with-test-prefix/c&e' instead of `with-test-prefix'.
  ["- wrong type argument"]: New test prefix.

13 years agoUse the `with-test-prefix/c&e' for the `1+' and `1-' tests.
Ludovic Courtès [Wed, 17 Nov 2010 22:05:50 +0000 (23:05 +0100)]
Use the `with-test-prefix/c&e' for the `1+' and `1-' tests.

* test-suite/tests/numbers.test ("1+"): Use `with-test-prefix/c&e'
  instead of `with-test-prefix'.  Provide a name to each `pass-if'
  invocation.
  ("1-"): Likewise.

13 years agoMove `with-test-prefix/c&e' to `(test-suite lib)'.
Ludovic Courtès [Wed, 17 Nov 2010 22:04:11 +0000 (23:04 +0100)]
Move `with-test-prefix/c&e' to `(test-suite lib)'.

* test-suite/tests/bytevectors.test (c&e, with-test-prefix/c&e): Move...
* test-suite/lib.scm: ... here.
  (with-test-prefix): Rewrite using `syntax-rules'.

13 years agoAdd `SCM_GNUC_PREREQ'.
Ludovic Courtès [Fri, 12 Nov 2010 08:54:49 +0000 (09:54 +0100)]
Add `SCM_GNUC_PREREQ'.

* libguile/__scm.h (SCM_GNUC_PREREQ): New macro.
  Use it in this file in lieu of hand-written GCC version tests.

13 years agoadd `reload-module' to boot-9
Andy Wingo [Thu, 18 Nov 2010 20:48:55 +0000 (21:48 +0100)]
add `reload-module' to boot-9

* module/ice-9/boot-9.scm (reload-module): New procedure,
  programmatically reloads the source file corresponding to the given
  module.

13 years agonumbers.test expects lower-case hexadecimals
Andy Wingo [Thu, 18 Nov 2010 15:06:46 +0000 (16:06 +0100)]
numbers.test expects lower-case hexadecimals

* test-suite/tests/numbers.test ("number->string"): Expect lower-case
  hexidecimals.

13 years agoread-set! takes effect at expand time
Andy Wingo [Thu, 18 Nov 2010 13:43:43 +0000 (14:43 +0100)]
read-set! takes effect at expand time

* module/ice-9/boot-9.scm (define-option-interface): The set! command
  goes in an eval-when to be run at expand-time, so that (read-set!
  keywords 'prefix) does what it used to in 1.8 (mostly).

13 years agorepl read/write using current ports, not captured ports
Andy Wingo [Thu, 18 Nov 2010 13:32:53 +0000 (14:32 +0100)]
repl read/write using current ports, not captured ports

Fixes bug in repl meta-commands after activating readline, which changes
the current input port.

* module/system/repl/common.scm (<repl>): Remove inport and outport
  fields.
  (make-repl): Adapt.
  (repl-read, repl-print): Just read and write to the current ports.

* module/system/repl/repl.scm (meta-reader): Meta-read from the current
  input port.

* module/system/repl/command.scm (read-command, define-meta-command):
  Read from the current input port.