Re: Warning: reference to free variable `begin'

David Kastrup <[email protected]> Fri, 18 Mar 2005 19:28:56 +0100
Newsgroups gmane.emacs.auc-tex
Message-ID <[email protected]>
Ralf Angeli <[email protected]> writes:

> * David Kastrup (2005-03-18) writes:
>
>> Me neither.  Outside of advice, I think this might be supposed to
>> work.  Not too sure about that, though.
>
> No, it won't.  Try `M-x compile-defun RET' on the following function:
>
> (defun foo ()
>   (and (boundp 'begin) begin))
>
> However, it will work if you replace `and' by `if'.  A while back
> there was a discussion on emacs-devel to teach the byte compiler other
> variants like `and' or `when' as well.  Obviously this hasn't made its
> way into Emacs yet.

(defmacro when (cond &rest body)
  "If COND yields non-nil, do BODY, else return nil."
  (declare (indent 1) (debug t))
  (list 'if cond (cons 'progn body)))

So `when' should already be catered for.  Anyway, I think we'll keep
with symbol-value.  That appears safe.

I don't have a clue why the compiler gets called at load time, anyway,
if we have valid preactivated advice.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum