[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Science to suppress compiler warnings
From: |
Davis Herring |
Subject: |
Re: Science to suppress compiler warnings |
Date: |
Tue, 2 Jun 2009 16:36:22 -0700 (PDT) |
User-agent: |
SquirrelMail/1.4.8-5.7.lanl1 |
> Elisp manual at "Compiler Errors" section (16.6) says we should
> conditionalize variable use with a boundp test (same thing for
> undefined function) but I find it very unpractical.
>
> I thought (probably was wrong) that:
>
> (eval-when-compile (defvar foo nil))
>
> would do the trick. Is it the correct way to avoid warnings ?
That should work if you have confidence that it will be defined (and
non-void) at runtime. The [f]boundp, of course, will let you react to it
not existing then, if there's a real possibility (as with an old Emacs
version) of it not being there.
> Also while at it, here is what I got when compiling an old
> package:
>
> records.el:931:49:Warning: reference to free variable
> `records-link-menu-map'
>
> In records-mode:
> records.el:1066:23:Warning: assignment to free variable
> `records-link-menu-map'
>
> What is the difference between these two warnings exactly ?
> Adding a defvar at the right place fixed that but to feed my
> curiosity.
The first is for reading, the second for writing; that's all.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.