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

1422 commits

Author SHA1 Message Date
Andy Wingo
998191fd4f fix testing code in web/server
* module/web/server.scm (call-with-encoded-output-string): Fix some code
  I accidentally left in while testing. Re-tested the difference in
  speed; pleasantly surprised.

* module/web/uri.scm: Make the same change here.
2010-12-12 23:34:18 +01:00
Andy Wingo
a6b1b27aad foreign: c-struct parsing simplification
* module/system/foreign.scm: Revert much of fb636a1cce. Short et al are
  not distinct types -- they are all aliases to e.g. int16. The only
  case that was not covered before was the pointer case.
  (bytevector-pointer-ref, bytevector-pointer-set!): Implement these,
  and use them for pointers.
2010-12-12 23:13:08 +01:00
Andy Wingo
ec3c7570d8 http-read robustness
* module/web/server/http.scm (http-read): Record the client index in
  more cases in which code could throw an error.
2010-12-12 21:59:29 +01:00
Andy Wingo
c7857da63a (web uri) can uri-decode non-utf-8 payloads
* module/web/uri.scm (call-with-encoded-output-string, encode-string):
  Copy from server.scm
  (decode-string): Copy from tekuti.
  (uri-decode): The #:charset arg is a string, like
  port-encoding. Support other charsets.
  (uri-encode): Charset is a string. Other encodings still not nicely
  supported. Hmm.
2010-12-11 19:19:41 +01:00
Andy Wingo
9582b26c62 add return/values hack to compile-glil for lua
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add a hack
  like 'return but for multiple values, for lua.
2010-12-10 18:04:06 +01:00
Andy Wingo
ed3fd27adb rnrs control only depends on (guile)
* module/rnrs/control.scm: Depend only on (guile).
2010-12-10 18:04:02 +01:00
Andy Wingo
84b67e1971 fix self-tail-calls for lexical procs with optional, rest, or kwargs
* module/language/tree-il/compile-glil.scm (flatten-lambda): Don't emit
  a self-label, because when we can't match the args for a lexical call,
  we have no space to shuffle args and jump.
  (flatten): Apply the self-tail-call optimization to optional args
  too, but only if the procedure is fix-allocated. If we can't apply the
  optimization, use the normal tail-call sequence.

* test-suite/tests/optargs.test ("lambda* inits"): Add tests.
2010-12-10 16:07:58 +01:00
Andy Wingo
3b24aee6e3 clarify compile-glil error messages
* module/language/tree-il/compile-glil.scm (vars->bind-list, flatten):
  Make internal self-checking error messages more clear, for
  implementors of other languages.
2010-12-09 21:53:46 +01:00
Andreas Rottmann
3df539b1a5 Get rid of `define-macro' in the SRFI 26 implementation
* module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'.
  The new implementation is mostly just a transcription of the old code;
  the reference implementation which relies only on `syntax-rules' may
  (or may not) be considered more elegant :-).

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2010-12-07 23:13:55 +01:00
Ludovic Courtès
51fc066ae2 Use `current-processor-count' to determine the number of future-workers.
* module/ice-9/futures.scm (%worker-count): Use
  `current-processor-count'.

* doc/ref/api-scheduling.texi (Futures): Add note about side-effects and
  I/O.  Mention `current-processor-count'.
2010-12-07 23:13:20 +01:00
Ludovic Courtès
a94469c651 Add a record type printer for vlists/vhashes.
* module/ice-9/vlist.scm (<vlist>): Add a record type printer.
2010-12-07 23:13:19 +01:00
Brian Templeton
c6920dc8ba lexical function binding for elisp
* module/language/elisp/compile-tree-il.scm (access-variable)
  (reference-variable, set-variable!): Handle globally-bound non-special
  variables.

  (bind-lexically?): Create lexical bindings for flet and flet*.

* module/language/elisp/runtime.scm (reference-variable, set-variable!):
  Handle globally-bound non-special variables.

  (built-in-func): Set the variable directly instead of storing the
  function in a fluid.

* module/language/elisp/runtime/subrs.scm (funcall): Call apply
  directly.

* test-suite/tests/elisp-compiler.test ("Function Definitions")["flet
  and flet*"]:

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:03 +01:00
Brian Templeton
3f70b2dc5c 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>
2010-12-07 13:21:03 +01:00
Brian Templeton
67cb2c2761 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>
2010-12-07 13:21:03 +01:00
Brian Templeton
b41a673d26 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>
2010-12-07 13:21:03 +01:00
Brian Templeton
b7966c10ef 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>
2010-12-07 13:21:02 +01:00
Brian Templeton
f5742cf042 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>
2010-12-07 13:21:02 +01:00
Brian Templeton
0dbfdeefc6 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.
2010-12-07 13:21:02 +01:00
Brian Templeton
44ae163d2c 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.
2010-12-07 13:21:02 +01:00
Brian Templeton
2ce5e74073 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'.
2010-12-07 13:21:02 +01:00
Brian Templeton
65b46b7241 allow fluid macro bindings
* module/language/elisp/compile-tree-il.scm (define-macro!, get-macro):
  Allow fluid macro bindings.
2010-12-07 13:21:02 +01:00
Brian Templeton
9efe5b230d new `load' subr
* module/language/elisp/runtime/subrs.scm: Define new subr `load'.
* module/language/elisp/runtime/function-slot.scm: Re-export `load'.
2010-12-07 13:21:02 +01:00
Brian Templeton
3829919663 Ignore #:warnings compiler option
* module/language/elisp/compile-tree-il.scm (process-options!): Ignore
  #:warnings compiler option.
2010-12-07 13:21:02 +01:00
Brian Templeton
1dfe593954 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>
2010-12-07 13:21:02 +01:00
Brian Templeton
8295b7c4e5 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>
2010-12-07 13:21:02 +01:00
Brian Templeton
6e9ebc9179 use existing bindings record for defmacro
* module/language/elisp/compile-tree-il.scm (compile-pair): Use existing
  bindings record during macro definition.
2010-12-07 13:21:02 +01:00
Brian Templeton
eda83f0ac9 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>
2010-12-07 13:21:01 +01:00
Brian Templeton
f4e5e4114d 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>
2010-12-07 13:21:01 +01:00
Brian Templeton
c983a199d8 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>
2010-12-07 13:21:01 +01:00
Brian Templeton
abcf4a9e1d 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>
2010-12-07 13:21:01 +01:00
Brian Templeton
9c933e1d3f autoload compile-file in (guile-user)
* module/ice-9/boot-9.scm (guile-user): Autoload `compile-file'.
2010-12-07 13:21:01 +01:00
Andy Wingo
4595600a08 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.
2010-12-06 19:52:51 +01:00
Andy Wingo
e9634465e3 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.
2010-12-06 19:27:22 +01:00
Andy Wingo
a9a2065540 fix name...
* module/web/request.scm (read-request-body/latin-1): Fix name...
2010-12-06 15:32:13 +01:00
Andy Wingo
e46f69e25c 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.
2010-12-06 15:30:45 +01:00
Andy Wingo
9eed1010e7 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.
2010-12-06 13:52:56 +01:00
Andy Wingo
adcd58543c fix entity tag writing
* module/web/http.scm (write-entity-tag): Fix writing of entity tags
  (strong versus weak).
2010-12-06 12:58:16 +01:00
Andy Wingo
b500ced6b8 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.
2010-12-06 11:24:48 +01:00
Andy Wingo
4164be30d3 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.
2010-12-05 20:24:14 +01:00
Andy Wingo
e8c44a044f (web server http) comment
* module/web/server/http.scm: Add comment about charsets.
2010-12-04 19:45:51 +01:00
Andy Wingo
f3d390939b 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.)
2010-12-04 19:45:09 +01:00
Andy Wingo
8556760c23 read-delimited is clearer and conses less
* module/ice-9/rdelim.scm (read-delimited): Clarify and somewhat
  optimize implementation.
2010-12-03 18:04:09 +01:00
Andy Wingo
80993fa438 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.
2010-12-03 17:37:22 +01:00
Andy Wingo
35b97af9d6 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.
2010-12-03 16:41:46 +01:00
Andy Wingo
e6ae317306 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.
2010-12-03 16:30:52 +01:00
Andy Wingo
0baead3f6e 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.
2010-12-03 16:11:37 +01:00
Andy Wingo
462a1a04cf (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.
2010-12-03 15:31:57 +01:00
Andy Wingo
6f81b18abe 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.
2010-12-03 15:16:37 +01:00
Ludovic Courtès
0d4e6ca38f 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.
2010-12-03 00:38:29 +01:00
Andy Wingo
6901bad07d sxml->xml fix
* module/sxml/simple.scm (attribute-value->xml): Whoops, fix null case.
2010-12-02 22:24:26 +01:00