Ludovic Courtès [Tue, 2 Mar 2010 22:36:29 +0000 (23:36 +0100)]
Fix "coding:" cookies in the test suite.
* test-suite/tests/bytevectors.test, test-suite/tests/keywords.test,
test-suite/tests/procprop.test, test-suite/tests/srfi-35.test,
test-suite/tests/srfi-88.test: Add "coding:" cookie on the first line.
Ludovic Courtès [Tue, 2 Mar 2010 22:16:26 +0000 (23:16 +0100)]
Fix off-by-one error when initializing vectors in `make-srfi-4-vector'.
* libguile/srfi-4.c (scm_make_srfi_4_vector): When FILL is bound and
non-zero, initialize the last element.
* test-suite/tests/srfi-4.test ("TAG vectors")["make-TAGvector"]: New
tests.
Ken Raeburn [Sun, 21 Feb 2010 20:13:10 +0000 (15:13 -0500)]
Use libguile/control.x explicitly.
Julian Graham [Tue, 2 Mar 2010 03:15:45 +0000 (22:15 -0500)]
Change failing syncase test case to UNRESOLVED.
* test-suite/tests/syncase.test:
("expander detects changes to current-module"): Throw 'unresolved instead of
returning #f.
Julian Graham [Sat, 27 Feb 2010 20:04:56 +0000 (15:04 -0500)]
add (currently failing) test case for changing the current module inside
`begin' form
* test-suite/tests/syncase.scm: ("expander detects changes to current-module"):
New test case.
Andy Wingo [Fri, 26 Feb 2010 12:05:25 +0000 (13:05 +0100)]
rewinding prompts works
* libguile/control.h (SCM_PROMPT_HANDLER): Remove, it was unused.
(SCM_PROMPT_DYNWINDS): Rename from SCM_PROMPT_DYNENV.
* libguile/control.c: (scm_c_make_prompt): Take another arg, the winds
that are to be in place for the prompt. Fix allocation to be 4 words
instead of 5 (the handler was never used).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt to scm_c_make_prompt change.
* libguile/vm-i-system.c (partial-cont-call): Grovel the new elements of
the wind list in order to call setjmp() on the new prompts. Pass
cookie to vm_reinstate_partial_continuation.
(prompt): Adapt to scm_c_make_prompt change.
* libguile/vm.c (vm_reinstate_partial_continuation): Take a cookie arg,
used when winding captured prompts onto the stack. Winding a prompt
implies making a new prompt, actually -- with new registers, a new
jump buffer, new winds, etc.
* test-suite/tests/control.test ("rewinding prompts"): Add a test for
rewinding prompts.
Andy Wingo [Sun, 31 Jan 2010 12:02:39 +0000 (13:02 +0100)]
catch, throw, with-throw-handler implemented in Scheme
* libguile/throw.c (tc16_jmpbuffer, tc16_pre_unwind_data): Remove these
smob types, and associated constructors and accessors (all internal).
(scm_catch, scm_catch_with_pre_unwind_handler):
(scm_with_throw_handler, scm_throw): Simply dispatch to scheme.
Lovely.
(tc16_catch_closure): Introduce a new applicable smob type, for use by
the C catch interface. All constructors and accessors are internal.
(scm_c_catch, scm_internal_catch, scm_c_with_throw_handler): Build
applicable smobs out of the C procedure arguments, so we can then
dispatch through scm_catch et al.
(scm_ithrow): Dispatch to scm_throw.
(pre_init_catch, pre_init_throw): Restricted catch/throw
implementation for use before boot-9 runs.
(scm_init_throw): Bind the pre-init catch and throw definitions.
* module/ice-9/boot-9.scm (prompt, abort): Move these definitions up in
the file.
(catch, throw, with-throw-handler): Implement in Scheme. Whee!
Andy Wingo [Sun, 31 Jan 2010 11:35:19 +0000 (12:35 +0100)]
deprecate lazy-catch
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_lazy_catch, scm_lazy_catch):
Deprecate, and print out a nasty warning that people should change to
with-throw-handler.
* libguile/throw.h:
* libguile/throw.c (scm_c_with_throw_handler): Deprecate the use of the
lazy_catch_p argument, printing out a nasty warning if someone
actually passes 1 as that argument. The combination of the pre-unwind
and post-unwind handlers should be sufficient.
* test-suite/tests/exceptions.test: Remove lazy-catch tests, as they are
deprecated. Two of them fail:
* throw/catch: effect of lazy-catch unwinding on throw to another key
* throw/catch: repeat of previous test but with lazy-catch
Hopefully people are not depending on this behavior, and the warning is
sufficiently nasty for people to switch. We will see.
* test-suite/tests/eval.test ("promises"): Use with-throw-handler
instead of lazy-catch.
* doc/ref/api-debug.texi:
* doc/ref/api-control.texi: Update to remove references to lazy-catch,
folding in the useful bits to with-throw-handler.
Andy Wingo [Thu, 25 Feb 2010 16:33:12 +0000 (17:33 +0100)]
fix a prompt bug
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Instead of taking a VM arg,
take the registers directly.
(scm_c_abort): Declare as returning void. In fact it will never
return.
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Adapt to prompt API change.
* libguile/vm-i-system.c (prompt): Pass the abort ip as the ip to
scm_c_make_prompt. This fixes a bug in which we used the "offset"
local var, but it wasn't guaranteed to be around after a longjmp.
Andy Wingo [Thu, 25 Feb 2010 12:17:34 +0000 (13:17 +0100)]
simplify handling of nonlocal prompt returns from c
* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): New helper.
* libguile/eval.c (eval): Use the new helper.
Andy Wingo [Wed, 24 Feb 2010 23:41:03 +0000 (00:41 +0100)]
more substance to control.test
* test-suite/tests/control.test ("suspend/resume with fluids"):
("restarting partial continuations"):
("reified continuations", "escape-only continuations"): More tests.
eval.scm's handling of with-fluids doesn't leave the VM
* module/ice-9/eval.scm (primitive-eval): Implement with-fluids in terms
of with-fluids, to avoid recursively calling the VM via with-fluids*.
Andy Wingo [Wed, 24 Feb 2010 23:32:40 +0000 (00:32 +0100)]
eval.scm's handling of with-fluids doesn't leave the VM
* module/ice-9/eval.scm (primitive-eval): Implement with-fluids in terms
of with-fluids, to avoid recursively calling the VM via with-fluids*.
Andy Wingo [Wed, 24 Feb 2010 23:18:07 +0000 (00:18 +0100)]
error if given an unrewindable partial continuation
* libguile/vm-engine.c (vm_error_continuation_not_rewindable):
* libguile/vm-i-system.c (partial-cont-call):
* libguile/vm.h (SCM_VM_CONT_PARTIAL_P):
(SCM_VM_CONT_REWINDABLE_P): Fix a bug in which we weren't checking if
a partial continuation was actually rewindable.
Andy Wingo [Wed, 24 Feb 2010 23:43:44 +0000 (00:43 +0100)]
fix embarrassing bug
* libguile/vm.c: Fix embarrassing error regarding the symbolitude of
vm-error and friends.
Andy Wingo [Wed, 24 Feb 2010 22:33:20 +0000 (23:33 +0100)]
start of tests for (ice-9 control)
* test-suite/Makefile.am:
* test-suite/tests/control.test: Add the beginnings of a delimited
continuations test suite.
Andy Wingo [Wed, 24 Feb 2010 22:32:04 +0000 (23:32 +0100)]
fix symbol initialization in vm.c
* libguile/vm.c (scm_bootstrap_vm): Fix case in which some symbols
wouldn't be initialized by the time they were needed.
Andy Wingo [Wed, 24 Feb 2010 22:20:38 +0000 (23:20 +0100)]
(ice-9 control) fixes
* module/ice-9/control.scm (%): Fix to allow tagged and default-tagged
prompts.
(abort): Re-export.
Andy Wingo [Wed, 24 Feb 2010 22:19:41 +0000 (23:19 +0100)]
fix escape-only prompts
* libguile/control.c (scm_c_make_prompt): Whoops, set the escape-only
flag properly here.
Andy Wingo [Wed, 24 Feb 2010 17:55:34 +0000 (18:55 +0100)]
add %default-prompt-tag, and error (not abort()) on an abort to bad tag
* libguile/init.c (scm_i_init_guile): Call scm_init_control after
initing fluids.
* libguile/control.h (scm_sys_default_prompt_tag): New internal var.
* libguile/control.c (scm_c_abort): If abort is called for an unknown
tag, raise an exception, except if the tag was the default prompt tag,
in which case really abort -- to prevent recursion when some other
patches land.
(scm_init_control): Define %default-prompt-tag in the default
environment.
Andy Wingo [Wed, 24 Feb 2010 17:51:25 +0000 (18:51 +0100)]
turn abort() calls in vm.c into exceptions
* libguile/vm.c (vm_return_to_continuation, vm_abort):
(vm_reinstate_partial_continuation, really_make_boot_program): Turn
some abort()s into scm_misc_errors.
Andy Wingo [Wed, 24 Feb 2010 16:43:02 +0000 (17:43 +0100)]
rewind the dynamic state when entering a partial continuation
* libguile/control.c (cont_objcode):
* libguile/vm-i-system.c (partial-cont-call):
* libguile/vm.c (vm_reinstate_partial_continuation): Don't keep the
"external winds" in a partial continuation, as they aren't logically
part of the continuation. Reinstate the "internal winds" when entering
a partial continuation. Things seem to work!
Andy Wingo [Wed, 24 Feb 2010 15:56:45 +0000 (16:56 +0100)]
partial-cont-call works
* libguile/vm-i-system.c (partial-cont-call): Sync registers before
splatting a partial continuation, and cache them back afterwards.
* libguile/vm.c (vm_reinstate_partial_continuation): Actually implement,
except dynamic-wind.
Andy Wingo [Wed, 24 Feb 2010 15:56:05 +0000 (16:56 +0100)]
record IP in partial continuations
* libguile/control.c (reify_partial_continuation): Assert some
invariants, and record the IP as the MVRA of the continuation.
Andy Wingo [Tue, 23 Feb 2010 23:32:07 +0000 (00:32 +0100)]
ensure non-escape-only prompts have a thunk application as their body
* module/language/tree-il/inline.scm (inline!): Fix indenting for
lambda-case. In an amusing turn of events, use the inliner to
de-inline prompt bodies, if the prompt is not escape-only.
Andy Wingo [Mon, 22 Feb 2010 22:00:19 +0000 (23:00 +0100)]
actually capture partial continuations
* libguile/control.c (cont_objcode): Along with a bunch of boilerplate
that certainly needs to go in some central place, define this
continuation-calling trampoline.
(reify_partial_continuation): New function, returns a procedure that
when called will reinstate a partial continuation.
(scm_c_abort): Take an extra arg, the cookie. Actually reify a
continuation.
(scm_at_abort): Adapt to scm_c_abort change.
* libguile/control.h: Declare scm_c_abort change.
* libguile/vm-i-system.c (partial_cont_call): New instruction.
(call/cc, tail-call/cc): Adapt to scm_i_vm_capture_stack change.
(abort): Pass vm_cookie to abort.
* libguile/vm.h (SCM_F_VM_CONT_PARTIAL, SCM_F_VM_CONT_REWINDABLE): New
flags.
(struct scm_vm_cont): Add flags field.
(SCM_VM_CONT_PARTIAL_P, SCM_VM_CONT_REWINDABLE_P): New predicates.
* libguile/vm.c (scm_i_vm_capture_stack): Rename from
vm_capture_continuation, and make internal instead of static. Take a
flags argument.
(scm_i_vm_capture_continuation): Adapt to scm_i_vm_capture_stack
change.
(vm_abort): Plumb cookie to scm_c_abort.
(vm_reinstate_partial_continuation): New stub.
Andy Wingo [Mon, 22 Feb 2010 21:41:34 +0000 (22:41 +0100)]
tweaks to default program printer
* libguile/programs.c (scm_i_program_print): Instead of printing the
address of the objcode, print the address of the program itself. Also
for continuations.
Andy Wingo [Mon, 22 Feb 2010 20:53:24 +0000 (21:53 +0100)]
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
Andy Wingo [Mon, 22 Feb 2010 19:29:10 +0000 (20:29 +0100)]
prompt and abort inlining
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add abort.
(*primitive-expand-table*): Fix so that we inline `prompt' and
`abort', and remove obsolete code dealing in `control'.
Andy Wingo [Mon, 22 Feb 2010 19:19:32 +0000 (20:19 +0100)]
fix <prompt> compilation bug
* module/language/tree-il/analyze.scm (analyze-lexicals): Fix bug
analysing <prompt> expressions.
Andy Wingo [Fri, 19 Feb 2010 21:44:24 +0000 (22:44 +0100)]
prompt as part of guile's primitive language
* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
(scm_c_make_prompt): Remove handler arg, as the handler is inline.
(scm_abort): New primitive, exported to Scheme as `abort'. The
compiler will also recognize calls to `abort', but this is the base
case.
(scm_init_control): Remove scm_register_control, just have this
function, which adds `abort' to the `(guile)' module.
* libguile/eval.c (eval): Add SCM_M_PROMPT case.
* libguile/init.c (scm_i_init_guile): Change scm_register_control call
into a nice orderly scm_init_control call.
* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
prompt support to the memoizer.
* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
stack.
* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.
* module/ice-9/control.scm: Simplify, and don't play with the compiler
here, now that prompt and abort are primitive.
* module/ice-9/eval.scm (primitive-eval): Add a prompt case.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add @prompt and prompt.
Andy Wingo [Fri, 19 Feb 2010 21:35:00 +0000 (22:35 +0100)]
fix prompt disassembly bug
* module/language/assembly/disassemble.scm (code-annotation): Fix a bug
disassembling `prompt'.
Andy Wingo [Fri, 19 Feb 2010 15:55:36 +0000 (16:55 +0100)]
add scm_c_abort, wire it up to the abort opcode
* libguile/control.h:
* libguile/control.c (scm_c_abort): Add an implementation of `abort',
but it doesn't reify the continuation yet.
* libguile/vm-i-system.c (abort):
* libguile/vm.c (vm_abort): Wire up the call to `abort', avoiding
consing the args into a list.
* module/language/tree-il/compile-glil.scm (flatten): Add some compily
bits that can allow the abort to be resumed.
Andy Wingo [Fri, 19 Feb 2010 14:30:34 +0000 (15:30 +0100)]
prompt handlers are always inline
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_PROMPT_INLINE_P): Remove;
prompts always have "inline" handlers now.
* libguile/control.c (scm_c_make_prompt): Remove inline_handler_p arg.
* libguile/vm-i-system.c (prompt):
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Adapt to prompt changes.
* module/language/glil.scm (make-glil-prompt, glil-prompt-inline?):
Remove inline? flag.
(parse-glil, unparse-glil):
* module/language/glil/compile-assembly.scm (glil->assembly): Adapt to
<glil-prompt> change.
* module/language/tree-il/compile-glil.scm (flatten): Require the
handler of a <prompt> to be a lambda-case.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
Ensure that the handler of a <prompt> is a lambda-case.
* module/language/tree-il/inline.scm (inline!): Simplify a degenerate
case: (lambda args (apply (lambda ...) args)) => (lambda ...).
Andy Wingo [Fri, 19 Feb 2010 10:50:51 +0000 (11:50 +0100)]
fluid-ref / fluid-set! compile to dynref/dynset
* module/language/tree-il/primitives.scm: Resolve fluid-ref and
fluid-set! as primitives, and thence to dynref/dynset.
Andy Wingo [Fri, 19 Feb 2010 10:42:00 +0000 (11:42 +0100)]
add <dynref> and <dynset> to tree-il
* module/language/tree-il.scm (<dynref>, <dynset>): New tree-il language
elements, corresponding to fluid-ref and fluid-set.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm: Wire them up in the usual
manner.
Andy Wingo [Fri, 19 Feb 2010 10:40:09 +0000 (11:40 +0100)]
new VM operations: fluid-ref, fluid-set
* libguile/vm-i-system.c (fluid-ref, fluid-set): New VM ops.
Andy Wingo [Fri, 19 Feb 2010 10:39:44 +0000 (11:39 +0100)]
fluids.h exposes more of its interface, internally at least
* libguile/fluids.h (SCM_I_FLUID_P, SCM_I_FLUID_NUM)
(SCM_I_DYNAMIC_STATE_P, SCM_I_DYNAMIC_STATE_FLUIDS): Expose these
predicates and accessors, internally at least.
* libguile/fluids.c (IS_FLUID, FLUID_NUM, IS_DYNAMIC_STATE)
(DYNAMIC_STATE_FLUIDS): Implement in terms of the exposed macros.
Andy Wingo [Fri, 19 Feb 2010 10:37:42 +0000 (11:37 +0100)]
vm caches the dynamic state in a local var
* libguile/vm-engine.c (vm_engine): Cache the dynamic state in a local
var when we enter the VM.
* libguile/vm-i-system.c (wind-fluids, unwind-fluids): Use the cached
dynamic state instead of going through SCM_I_CURRENT_THREAD.
Andy Wingo [Fri, 19 Feb 2010 09:49:24 +0000 (10:49 +0100)]
rename <control> to <abort>
* libguile/vm-i-system.c (abort): Rename instruction from `throw'.
* libguile/vm.c (vm_abort): Rename from vm_throw.
* module/language/tree-il.scm (<abort>, make-abort, abort-src,
abort-tag, abort-args: Rename from <control> & company.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/primitives.scm: Fix all callers.
Andy Wingo [Thu, 18 Feb 2010 22:56:12 +0000 (23:56 +0100)]
<prompt> has no pre-unwind-handler, it's unnecessary
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt, SCM_PROMPT_PRE_UNWIND_HANDLER):
* libguile/vm-i-system.c (prompt)
* module/language/tree-il.scm (<prompt> prompt-pre-unwind-handler):
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm: Remove the "pre-unwind"
handler from prompt; it turns out not to be necessary. Adapt all
references.
Andy Wingo [Fri, 19 Feb 2010 11:07:40 +0000 (12:07 +0100)]
re-expand psyntax-pp
* module/ice-9/psyntax-pp.scm: Expand again so we actually use
with-fluids.
Andy Wingo [Fri, 19 Feb 2010 11:07:02 +0000 (12:07 +0100)]
fix tree-il->scheme bug for <dynlet>
* module/language/tree-il.scm (tree-il->scheme): Bugfix for dynlet.
Andy Wingo [Thu, 18 Feb 2010 21:11:57 +0000 (22:11 +0100)]
psyntax support for with-fluids
* module/ice-9/psyntax.scm (build-dynlet, with-fluids): Use psyntax to
recognize `with-fluids' as a core form, producing <dynlet> if we are
compiling.
(sc-expand): To spice up the mix, use with-fluids here in the
implementation.
* module/ice-9/psyntax-pp.scm: Bootstrapped twice (!).
* module/ice-9/boot-9.scm: Remove with-fluids definition, it's in the
core now.
Andy Wingo [Thu, 18 Feb 2010 17:43:21 +0000 (18:43 +0100)]
add tree-il->glil compilation for dynlet
* module/language/tree-il/compile-glil.scm (flatten): Compile <dynlet>.
Andy Wingo [Thu, 18 Feb 2010 17:42:54 +0000 (18:42 +0100)]
add wind-fluids, unwind-fluids VM ops
* libguile/vm-i-system.c (wind-fluids, unwind-fluids): New instructions,
for dynamic binding.
Andy Wingo [Thu, 18 Feb 2010 17:05:24 +0000 (18:05 +0100)]
add dynlet to tree-il
* module/language/tree-il.scm (<dynlet>, dynlet?, make-dynlet)
(dynlet-src, dynlet-fluids, dynlet-vals, dynlet-body): New tree-il
construct, mapping to `with-fluids'.
(parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold):
(make-tree-il-folder, post-order!, pre-order!): Wire it up.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add dynlet
support.
Andy Wingo [Thu, 18 Feb 2010 16:10:29 +0000 (17:10 +0100)]
add with-fluids objects and primitive syntax
* libguile/tags.h (scm_tc7_with_fluids): Allocate a tc7 for
"with-fluids" objects, which will only live on the dynamic stack (wind
list), not in normal scheme-land.
* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_WITH_FLUIDS_LEN)
(SCM_WITH_FLUIDS_NTH_FLUID, SCM_WITH_FLUIDS_NTH_VAL)
(SCM_WITH_FLUIDS_SET_NTH_VAL): Add some accessors.
* libguile/fluids.c (scm_i_make_with_fluids, scm_i_swap_with_fluids):
New internal functions.
(scm_c_with_fluids, scm_c_with_fluid): Push with-fluids objects on the
dynwind list, not winders.
* libguile/dynwind.c (scm_i_dowinds): Add cases for winding and
unwinding with-fluids objects.
* libguile/memoize.h (scm_sym_with_fluids, SCM_M_BEGIN): New public
data.
* libguile/memoize.c (scm_m_with_fluids): Define with-fluids as a
primitive syntax.
(unmemoize): Add with-fluids case.
* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Add with-fluids cases.
* test-suite/tests/fluids.test
("fluids not modified if nonfluid passed to with-fluids"): Enable a
now-passing test.
Andy Wingo [Wed, 17 Feb 2010 21:36:14 +0000 (22:36 +0100)]
add fluid tests
* test-suite/Makefile.am:
* test-suite/tests/fluids.test: Add some fluid tests. One is an XFAIL
right now.
Andy Wingo [Thu, 18 Feb 2010 16:23:49 +0000 (17:23 +0100)]
rename <dynamic-wind> to <dynwind>
* module/language/tree-il.scm (<dynwind>): Rename from <dynamic-wind>.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/primitives.scm:
* module/language/tree-il/compile-glil.scm: All accessors and callers
changed.
Andy Wingo [Thu, 18 Feb 2010 15:53:30 +0000 (16:53 +0100)]
fix unmemoization bug
* libguile/memoize.c (unmemoize): Fix unmemoization of memoized
toplevel-ref and module-ref forms.
Andy Wingo [Thu, 18 Feb 2010 15:50:57 +0000 (16:50 +0100)]
eval.c tweaks
* libguile/eval.c (eval): Fix a couple of uses of scm_cdr that should
use CDR.
Andy Wingo [Thu, 18 Feb 2010 15:50:26 +0000 (16:50 +0100)]
fix comment in continuations.c
* libguile/continuations.c: Fix a comment.
Andy Wingo [Thu, 18 Feb 2010 11:28:37 +0000 (12:28 +0100)]
memoize (begin foo) to foo
* libguile/memoize.c (memoize_sequence): Don't make a `begin' if there's
only one form.
Andy Wingo [Thu, 18 Feb 2010 15:59:41 +0000 (16:59 +0100)]
reorder eval clauses
* module/ice-9/eval.scm: Add a comment explaining the frequencies of the
various memoized expression types.
(eval): Reorder the cases based the profile.
Andy Wingo [Tue, 16 Feb 2010 22:01:09 +0000 (23:01 +0100)]
dynwind is now a part of guile's primitive language
* libguile/memoize.h (scm_sym_at_dynamic_wind, SCM_M_DYNWIND)
* libguile/memoize.c (memoized_tags, MAKMEMO_DYNWIND)
(scm_m_at_dynamic_wind, unmemoize): Add dynwind as a primitive
expression type.
* libguile/dynwind.c (scm_dynamic_wind): Downgrade to a normal C
function.
* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Add dynwind support.
* module/ice-9/r4rs.scm: More relevant docs.
(apply): Define in a more regular way.
(dynamic-wind): Add to this file, with docs, dispatching to
@dynamic-wind.
* module/language/tree-il/primitives.scm: Parse @dynamic-wind into a
tree-il dynamic-wind.
Ludovic Courtès [Wed, 17 Feb 2010 17:11:49 +0000 (18:11 +0100)]
Bump version number for 1.9.8.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
Ludovic Courtès [Wed, 17 Feb 2010 16:50:43 +0000 (17:50 +0100)]
Update to Gnulib
v0.0-3448-g6078aa4 for its <netdb.h> fix.
Reverts commit
691b9ec196203fa5d6da3530d5355b2f73e707d1 ("getaddrinfo:
Define macros lacking in NetBSD 5.0.").
* libguile/net_db.c (AI_ALL, AI_V4MAPPED, AI_ADDRCONFIG): Remove
placeholder definitions, how provided by Gnulib's <netdb.h>.
Andy Wingo [Wed, 17 Feb 2010 16:34:58 +0000 (17:34 +0100)]
slight NEWS tweaks
* NEWS: Slight tweaks.
Ludovic Courtès [Wed, 17 Feb 2010 00:14:26 +0000 (01:14 +0100)]
getaddrinfo: Define macros lacking in NetBSD 5.0.
* libguile/net_db.c (AI_ALL, AI_V4MAPPED, AI_ADDRCONFIG): New
macros, when not already defined.
Ludovic Courtès [Tue, 16 Feb 2010 23:50:24 +0000 (00:50 +0100)]
Update `NEWS'.
Ludovic Courtès [Tue, 16 Feb 2010 23:44:56 +0000 (00:44 +0100)]
Mention libffi dependency in `README'.
Ludovic Courtès [Tue, 16 Feb 2010 23:44:14 +0000 (00:44 +0100)]
Include <libguile/__scm.h> in "foreign.h".
* libguile/foreign.h: Include <libguile/__scm.h>.
Ludovic Courtès [Tue, 16 Feb 2010 23:31:04 +0000 (00:31 +0100)]
Remove misplaced tabs from the manual.
* doc/ref/posix.texi (Network Databases): Remove tabs from `getaddrinfo'
example.
* .dir-locals.el: Set `indent-tabs-mode' to `t' for `texinfo-mode'.
Andy Wingo [Tue, 16 Feb 2010 22:45:28 +0000 (23:45 +0100)]
a start at NEWS
* NEWS: A start at NEWS; now to sleep.
Andy Wingo [Tue, 16 Feb 2010 20:47:34 +0000 (21:47 +0100)]
delete the tutorial
* configure.ac:
* doc/Makefile.am:
* doc/tutorial/ChangeLog-2008:
* doc/tutorial/ChangeLog-guile-doc-tutorial:
* doc/tutorial/Makefile.am:
* doc/tutorial/guile-tut.texi: Remove the tutorial. The history was out
of date (whereas the manual is current), the C examples are no longer
valid (and the manual does provide C examples), it was incomplete, and
its first person no longer hacks on Guile. So tutorial, you had a good
run, but the manual does your job now!
Andy Wingo [Tue, 16 Feb 2010 20:35:57 +0000 (21:35 +0100)]
fix a bug in the tutorial
* doc/tutorial/guile-tut.texi (c_builtins.c): Fix a typo with an
undeclared variable. Thanks to Raimon Grau for the pointer. This
tutorial is quite out of date, though...
Andy Wingo [Tue, 16 Feb 2010 20:11:27 +0000 (21:11 +0100)]
`load' doesn't cause the compiler to be loaded in some cases
* module/system/base/compile.scm (compiled-file-name): Add a comment.
* module/ice-9/boot-9.scm (load): Avoid loading up (system base compile)
just to compute an autocompiled file name. Fixes the issue whereby
guile-tools snarf-check-and-output-texi was inadvertantly loading up
srfi-1, and thereby a stale library, just to see if guile-tools itself
had a compiled version.
Not sure what the right unit test is here, other than vigilance.
Ludovic Courtès [Tue, 16 Feb 2010 19:50:27 +0000 (20:50 +0100)]
Add missing $(LTLIBINTL), suggested by Gnulib.
* libguile/Makefile.am (libguile_la_LIBADD): Add $(LTLIBINTL).
Ludovic Courtès [Tue, 16 Feb 2010 19:46:49 +0000 (20:46 +0100)]
i18n: Define `nl_item' when it's not available (needed for Cygwin).
* configure.ac: Add check for `nl_item'.
* libguile/i18n.c: Separate check for `HAVE_LANGINFO_H' and
`HAVE_NL_TYPES_H'.
[!HAVE_NL_ITEM]: Define `nl_item'.
Ludovic Courtès [Tue, 16 Feb 2010 18:13:56 +0000 (19:13 +0100)]
Skip "wrong service name" `getaddrinfo' test on Darwin 9.2.
* test-suite/tests/net-db.test ("getaddrinfo")["wrong service name"]:
Skip test on Darwin 9.2.
Michael Gran [Tue, 16 Feb 2010 04:45:58 +0000 (20:45 -0800)]
Faster read of semicolon comments
There is no need to do character encoding processing within
semicolon comments.
* libguile/read.c (scm_read_semicolon_comment): changed
Ludovic Courtès [Mon, 15 Feb 2010 18:40:42 +0000 (19:40 +0100)]
Fix builds of `i18n.c' on non-GNU systems.
* libguile/i18n.c (chr_to_case, str_to_case): Add `func_name' argument
and `FUNC_NAME' macro. Update callers.
Ludovic Courtès [Mon, 15 Feb 2010 17:43:20 +0000 (18:43 +0100)]
Add `getaddrinfo' test.
* test-suite/tests/net-db.test ("getaddrinfo")["port 80 with family and
socket type"]: New test.
Ludovic Courtès [Mon, 15 Feb 2010 17:42:34 +0000 (18:42 +0100)]
Use `#f' for `addrinfo:canonname' when it wasn't supplied by getaddrinfo(3).
* libguile/net_db.c (scm_from_addrinfo): Use `#f' when `ai_canonname'
isn't set.
Ludovic Courtès [Mon, 15 Feb 2010 15:10:01 +0000 (16:10 +0100)]
Fix `getaddrinfo' tests.
Thanks to Ken Raeburn.
* test-suite/tests/net-db.test ("getaddrinfo")["port 80"]: Fix bogus
check of `addrinfo:flags' (POSIX says that the "contents of the
ai_flags field of the returned structures are undefined.").
("wrong service name"): Accept `EAI_NONAME' as a valid error code.
Ludovic Courtès [Sun, 14 Feb 2010 23:43:20 +0000 (00:43 +0100)]
Make the `getaddrinfo' "no name" test more robust.
* test-suite/tests/net-db.test ("getaddrinfo")["no name"]: Check for
`EAI_EAGAIN' too.
Ludovic Courtès [Sun, 14 Feb 2010 21:37:39 +0000 (22:37 +0100)]
Add missing Gnulib files; update `.gitignore'.
This files were missing from commit
61cd9dc907b8a09990b14e9aeac7e20fe77cecc6 ("Use Gnulib's `getaddrinfo'
module.").
Ludovic Courtès [Sun, 14 Feb 2010 19:56:31 +0000 (20:56 +0100)]
Add `getaddrinfo' and related procedures.
* libguile/net_db.c (sym_getaddrinfo_error, sym_ai_passive,
sym_ai_canonname, sym_ai_numerichost, sym_ai_numericserv,
sym_ai_v4mapped, sym_ai_all, sym_ai_addrconfig, sym_eai_badflags,
sym_eai_noname, sym_eai_again, sym_eai_fail, sym_eai_family,
sym_eai_socktype, sym_eai_service, sym_eai_memory, sym_eai_system,
sym_eai_overflow, sym_eai_nodata, sym_eai_addrfamily,
sym_eai_inprogress, sym_eai_canceled, sym_eai_notcanceled,
sym_eai_alldone, sym_eai_intr, sym_eai_idn_encode): New variables.
(scm_from_addrinfo, scm_getaddrinfo, scm_gai_strerror): New functions.
* libguile/net_db.h (scm_getaddrinfo, scm_gai_strerror): New functions.
* module/ice-9/networking.scm (addrinfo:flags, addrinfo:fam,
addrinfo:socktype, addrinfo:protocol, addrinfo:addr,
addrinfo:canonname): New procedures.
* test-suite/tests/net-db.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add `tests/net-db.test'.
* doc/ref/posix.texi (Network Databases)[getaddrinfo]: New subsection.
[The Host Database]: Suggest using `getaddrinfo'.
Ludovic Courtès [Sun, 14 Feb 2010 16:06:13 +0000 (17:06 +0100)]
Use Gnulib's `getaddrinfo' module.
* m4/gnulib-cache.m4: Add `getaddrinfo'.
* libguile/Makefile.am (libguile_la_LDFLAGS): Add `$(GETADDRINFO_LIB)
$(HOSTENT_LIB) $(SERVENT_LIB)'.
Thien-Thi Nguyen [Tue, 9 Feb 2010 13:29:36 +0000 (14:29 +0100)]
Document trailing whitespace policy.
* HACKING (Coding standards): Delete trailing whitespace.
Add blurb documenting trailing whitespace policy.
Signed-off-by: Thien-Thi Nguyen <ttn@gnuvola.org>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Sat, 13 Feb 2010 22:50:06 +0000 (23:50 +0100)]
Document the maximum number of arguments for a subr.
* doc/ref/api-procedures.texi (Primitive Procedures): Specify the
maximum number of arguments. Patch by guign@mails.selgrad.org.
Ludovic Courtès [Sat, 13 Feb 2010 18:33:51 +0000 (19:33 +0100)]
Reinstate `scm_protects', for backward compatibility.
Partly reverts
e7efe8e793fa51ea898aea4477939c598b3e9fac ("decruftify
scm_sys_protects").
* libguile/gc.c (protects): Rename to...
(scm_protects): ... this.
* libguile/gc.h (scm_protects): Add declaration.
Ludovic Courtès [Tue, 9 Feb 2010 23:39:25 +0000 (00:39 +0100)]
Fix documentation of the `string->utf' and `utf->string' functions.
* doc/ref/api-data.texi (Bytevectors as Strings): Describe optional
parameter of `string->utf{16,32}' and `utf{16,32}->string'.
Ludovic Courtès [Tue, 9 Feb 2010 23:34:05 +0000 (00:34 +0100)]
Use the R6RS I/O API in `write-bytecode'.
* module/language/assembly/compile-bytecode.scm
(write-bytecode)[u32-bv]: New variable.
[write-char, write-uint16-be, write-uint16-le, write-uint32-le]:
Remove.
[write-string, write-uint32-be, write-uint32, write-wide-string,
write-bytevector]: Rewrite using the `(rnrs io ports)' API.
[write-uint24-be]: Rename to...
[write-int24-be]: ... this. Use `(rnrs io ports)' API. Callers
updated.
[write-uint16]: Remove.
Ludovic Courtès [Fri, 5 Feb 2010 10:11:56 +0000 (11:11 +0100)]
Change `write-bytecode' to accept a bytevector.
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Replace the WRITE-BYTE and GET-ADDR parameters with PORT. New ADDRESS
and EMIT-OPCODE? parameters. Callers updated.
[write-byte, get-addr]: New procedures.
Adjust to write to PORT.
(compile-bytecode): Update accordingly.
* test-suite/tests/asm-to-bytecode.test (munge-bytecode): Return a
bytevector instead of a u8vector.
(comp-test): Deal with bytevectors.
Ludovic Courtès [Fri, 5 Feb 2010 09:38:38 +0000 (10:38 +0100)]
vlist: Slightly improve readability and consistency.
* module/ice-9/vlist.scm (define-inline): Fix case with non-singleton
body.
(make-vhash-assoc): Remove. Change to...
(%vhash-assoc): ... this, using `define-inline'.
Andy Wingo [Mon, 8 Feb 2010 21:59:25 +0000 (22:59 +0100)]
continuations return multiple values on the stack
* libguile/vm.h (struct scm_vm_cont): Instead of saving the "IP", save
"RA" and "MVRA". That is, save singly-valued and multiply-valued
return addresses, so that we can return multiple values on the stack.
(scm_i_vm_reinstate_continuation): Remove.
* libguile/vm.c (vm_capture_continuation): Rename from capture_vm_cont,
and change the prototype so we can capture the RA and MVRA, and so
that tail calls to call/cc can capture a continuation without the
call/cc application frame.
(vm_return_to_continuation): Rename from reinstate_vm_cont, and take
arguments to return to the continuation. Handles returning to single
or multiple-value RA.
(scm_i_vm_capture_continuation): Change to invoke
vm_capture_continuation. Kept around for the benefit of make-stack.
* libguile/vm-i-system.c (continuation-call): Handle reinstatement of
the VM stack, with arguments.
(call/cc, tail-call/cc): Adapt to new vm_capture_continuation
prototype. tail-call/cc captures tail continuations.
* libguile/stacks.c (scm_make_stack): Update for scm_vm_cont structure
change.
* libguile/continuations.h (struct scm_contregs): Remove throw_value
member, which was used to return a value to a continuation.
(scm_i_check_continuation): New internal function, checks that a
continuation may be reinstated.
(scm_i_reinstate_continuation): Replaces scm_i_continuation_call; just
reinstates the C stack.
(scm_i_contregs_vm, scm_i_contregs_vm_cont): New internal accessors.
* libguile/continuations.c (scm_i_make_continuation): Return
SCM_UNDEFINED if we are returning again.
(grow_stack, copy_stack_and_call, scm_dynthrow): Remove extra arg, as
vm opcodes handle value returns.
(copy_stack): No need to instate VM continuation.
(scm_i_reinstate_continuation): Adapt.
Andy Wingo [Sun, 7 Feb 2010 13:50:51 +0000 (14:50 +0100)]
scm_i_make_continuation takes vm and vm_cont args explicitly
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Take VM and VM
continuation arguments as well; I'm not convinced that saving all VM
continuations was the right thing, and in any case we only ever saved
the latest. Running a new VM should create a continuation barrier.
* libguile/stacks.c (scm_make_stack):
* libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers.
* libguile/vm.h (scm_i_vm_capture_continuation)
(scm_i_vm_reinstate_continuation): Change to be internal, and to only
capture and reinstate continuations for a particular VM.
Andy Wingo [Sun, 7 Feb 2010 13:16:54 +0000 (14:16 +0100)]
make scm_make_continuation internal
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Change from
scm_make_continuation, and make internal.
* libguile/vm-i-system.c (call/cc, tail-call/cc): Adapt callers.
* test-suite/standalone/test-unwind.c (check_cont_body): Adapt a test.
* doc/ref/api-control.texi (Continuations): Update docs.
Andy Wingo [Mon, 8 Feb 2010 12:33:21 +0000 (13:33 +0100)]
eval.c uses scm_i_call_with_current_continuation
* libguile/continuations.h
* libguile/continuations.c (scm_i_call_with_current_continuation): New
internal function. Not exported because I'm not sure whether or not
this should have a continuation barrier in the future. Uses a
hand-coded VM procedure.
* libguile/eval.c (eval): Use scm_i_call_with_current_continuation.
Andy Wingo [Sat, 6 Feb 2010 16:00:03 +0000 (17:00 +0100)]
continuations are vm procedures
* libguile/vm-i-system.c (continuation-call): New op, like subr-call or
foreign-call, but for continuations.
* libguile/continuations.h: Add scm_i_continuation_call internal
declaration.
(SCM_CONTINUATIONP): Reimplement in terms of
SCM_PROGRAM_IS_CONTINUATION.
(scm_tc16_continuation, SCM_CONTREGS, SCM_CONTINUATION_LENGTH)
(SCM_SET_CONTINUATION_LENGTH, SCM_JMPBUF, SCM_DYNENV, SCM_THROW_VALUE)
(SCM_CONTINUATION_ROOT, SCM_DFRAME): Remove these from the exposed
API.
(scm_i_continuation_to_frame): New internal declaration.
* libguile/continuations.c
* libguile/continuations.c: Add trickery like in foreign.c, smob.c, and
gsubr.c, so that we can make procedural trampolines for continuations.
(scm_i_continuation_to_frame): New internal function, from stacks.c.
* libguile/programs.h (SCM_F_PROGRAM_IS_CONTINUATION)
(SCM_PROGRAM_IS_CONTINUATION): Add a flag for programs that are
continuations. Probably should add flags for the other trampoline
types too.
* libguile/programs.c (scm_i_program_print): Print continuations as
before.
* libguile/stacks.c (scm_stack_id, scm_make_stack): Use
scm_i_continuation_to_frame in the continuation case.
Andy Wingo [Fri, 5 Feb 2010 10:30:53 +0000 (11:30 +0100)]
push a prompt handler value even in the inline-handler case
* module/language/tree-il/compile-glil.scm (flatten): Push a handler
value even in the inline-handler case, to make prompt's interface more
uniform, and also to correspond to the existing VM implementation.
Andy Wingo [Tue, 2 Feb 2010 21:59:55 +0000 (22:59 +0100)]
connect a few more wires to promptenstein
* libguile/tags.h (scm_tc7_prompt): Allocate a tc7 for prompt objects.
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_F_PROMPT_ESCAPE)
(SCM_PROMPT_P, SCM_PROMPT_FLAGS, SCM_PROMPT_INLINE_P)
(SCM_PROMPT_ESCAPE_P, SCM_PROMPT_TAG, SCM_PROMPT_REGISTERS)
(SCM_PROMPT_DYNENV, SCM_PROMPT_HANDLER)
(SCM_PROMPT_PRE_UNWIND_HANDLER, SCM_PROMPT_SETJMP)
(struct scm_prompt_registers):
* libguile/control.c (scm_c_make_prompt): Flesh out a simple prompts
implementation.
* libguile/vm-i-system.c (prompt): Wire up the implementation.
* libguile/vm.c: Add a needed #include.
Michael Gran [Wed, 3 Feb 2010 04:33:41 +0000 (20:33 -0800)]
Optimize reader by preferring stack-allocated buffers
* libguile/read.c (read_token): now takes a C buffer instead of a SCM.
string. All callers changed.
(read_complete_token): now takes C buffers, not SCM strings. No longer
does port position updates or encoding processing. All callers changed.
(scm_read_number, scm_read_mixed_case_symbol, scm_read_number_and_radix)
(scm_read_character): Do port updates and string processing no longer
done by read_complete_token. Some reordering for optimization.
Ludovic Courtès [Tue, 2 Feb 2010 22:58:03 +0000 (23:58 +0100)]
Use vhashes in `unused-variable-analysis'.
* module/language/tree-il/analyze.scm (unused-variable-analysis): Use
vhashes instead of alists/lists.
Ludovic Courtès [Tue, 2 Feb 2010 23:00:05 +0000 (00:00 +0100)]
Use vhashes in `arity-analysis'.
* module/language/tree-il/analyze.scm (arity-analysis): Use vhashes
instead of alists.
Ludovic Courtès [Tue, 2 Feb 2010 22:59:34 +0000 (23:59 +0100)]
Use vhashes in `unbound-variable-analysis'.
* module/language/tree-il/analyze.scm (unbound-variable-analysis): Use
vhashes instead of alists/lists.
Ludovic Courtès [Tue, 2 Feb 2010 22:59:03 +0000 (23:59 +0100)]
Use vhashes in `unused-toplevel-analysis'.
* module/language/tree-il/analyze.scm (graph-reachable-nodes): Add
REACHABLE argument. Update to use vhash instead of alists or lists.
(graph-reachable-nodes*): Adjust accordingly.
(partition*): New function.
(unused-toplevel-analysis): Adjust to use vhash instead of alists or
lists.
Ludovic Courtès [Tue, 2 Feb 2010 22:57:02 +0000 (23:57 +0100)]
Add `(ice-9 vlist)'.
* module/ice-9/vlist.scm, test-suite/tests/vlist.test,
benchmark-suite/benchmarks/vlists.bm: New files.
* module/Makefile.am (ICE_9_SOURCES): Add `vlist.scm'.
* test-suite/Makefile.am (SCM_TESTS): Add `tests/vlist.test'.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add
`benchmarks/vlists.bm'.
* doc/ref/api-compound.texi (VLists, VHashes): New nodes.
Ludovic Courtès [Sat, 30 Jan 2010 21:54:20 +0000 (22:54 +0100)]
Inline SRFI-9 constructors too.
* module/srfi/srfi-9.scm (define-record-type)[constructor]: Use
`define-inlinable' instead of `define'.
* test-suite/lib.scm (exception:syntax-pattern-unmatched): New variable.
* test-suite/tests/srfi-9.test ("constructor")["foo 0 args (inline)",
"foo 2 args (inline)"]: New tests.
["foo 0 args", "foo 2 args"]: Adjust to constructor inlining.
* testsuite/t-records.scm: Remove wrong-arg-count case.