guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @bind


From: Marius Vollmer
Subject: Re: @bind
Date: 07 Oct 2001 00:14:24 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Neil Jerram <address@hidden> writes:

> >>>>> "Marius" == Marius Vollmer <address@hidden> writes:
> 
>     Marius> Neil Jerram <address@hidden> writes:
>     >> One detail: in the case where @bind creates a new variable on
>     >> entry, should it destroy that variable on exit?
> 
>     Marius> I don't think it should go to that trouble.  The variable
>     Marius> will have SCM_UNDEFINED as its value in that case which
>     Marius> should be equivalent.
> 
> Well... `-)
> 
> address@hidden ~]$ guile -q
> guile> cond
> #<primitive-macro! cond>
> guile> (@bind ((cond 3)) cond)
> 3
> guile> cond
> <unnamed port>: In expression cond:
> <unnamed port>: Unbound variable: cond
> ABORT: (unbound-variable)
> 
> Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
> guile> 

Yeah, right.

> This is fixed by the patch below, but I don't know if it is the
> best possible patch.

Hmm, I'm still unclear about how we are going to handle undefining
variables.  What I said above about a variable with value
SCM_UNDEFINED being equivalent to a non-existent one was certainly
naive.

I think the ultimate plan is to undefine variables by removing them
from the obarray and redoing all lookups that have been cached and
could be affected by the change.

This, however, is unappropriate for implementing dynamic binding,
since it is very costly.  Maybe we should not try to do dynamic
binding using Scheme variables.  Instead we could use a more explicit
syntax like `(dynamic-ref var)', etc.

I will apply your patch, and also fix @bind so that it will look
beyond the current module before creating a new variable.

> Index: modules.c
> ===================================================================
> RCS file: /cvs/guile/guile-core/libguile/modules.c,v
> retrieving revision 1.33
> diff -u -r1.33 modules.c
> --- modules.c 2001/07/26 21:40:17     1.33
> +++ modules.c 2001/09/07 10:32:14
> @@ -278,7 +278,7 @@
>  {
>    /* 1. Check module obarray */
>    SCM b = scm_hashq_ref (SCM_MODULE_OBARRAY (module), sym, SCM_UNDEFINED);
> -  if (SCM_VARIABLEP (b))
> +  if (SCM_VARIABLEP (b) && !SCM_UNBNDP (SCM_VARIABLE_REF (b)))
>      return b;
>    {
>      SCM binder = SCM_MODULE_BINDER (module);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]