This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: `undefine' bug or feature?



> > (define a 1)
> > (define (l) (display a))
> > (l) -> 1
> > 
> > (undefine a)
> > (l) -> #<undefined>
> > 
> > 
> > I think it is better to let `undefine' remove the symbol completely instead
> > of setting its value to undefined.
> > 
> 
> I think this is a bug, udefined variables do get gc'd collectively,
> but until then, accessing a variable with an undefined value should
> throw an error as usual.

Yeah; the second call to l should act as if the (define a 1) were
completely missing, and throw an error.

If you can submit a patch, I'll look it over, but I think you'll find
it harder than you expected to fix this without slowing down the
interpreter a lot.  The reference to a is memoized into the list
structure of l.  To undefine some random variable, you have to run
around all the Scheme code in the system unmemoizing it.

I'm not sure that undefine is such a great function to support
anyway.