mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
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.
This commit is contained in:
parent
d107921794
commit
ef94624eaf
5 changed files with 92 additions and 12 deletions
|
@ -1612,7 +1612,15 @@ VM_DEFINE_INSTRUCTION (91, fluid_ref, "fluid-ref", 0, 1, 1)
|
|||
*sp = scm_fluid_ref (*sp);
|
||||
}
|
||||
else
|
||||
*sp = SCM_SIMPLE_VECTOR_REF (fluids, num);
|
||||
{
|
||||
SCM val = SCM_SIMPLE_VECTOR_REF (fluids, num);
|
||||
if (SCM_UNLIKELY (val == SCM_UNDEFINED))
|
||||
{
|
||||
finish_args = *sp;
|
||||
goto vm_error_unbound_fluid;
|
||||
}
|
||||
*sp = val;
|
||||
}
|
||||
|
||||
NEXT;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue