bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Bug in emacs


From: era
Subject: Re: Bug in emacs
Date: 14 Oct 2003 09:05:20 +0300
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

On Mon, 13 Oct 2003 10:28:06 -0600, Kevin Rodgers <ihs_4664@yahoo.com>
posted to gmane.emacs.bugs:
 > era@iki.fi wrote:
 >> I'm not sure what the bug really is. Perhaps it would be useful to
 >> get a warning when compiling / evaling something when a macro +is+
 >> in effect and the file you are compiling is not pulling it in
 >> properly? Then at least you get a hint to fix it while you still
 >> can, while those who do it right will not experience any adverse
 >> effects.
 > When the compiler comes across a (function arg ...) form, either the
 > function is defined or it isn't.  If it's defined, either as a function
 > or a macro, all is well.  If it's not defined, the compiler can't know
 > whether it is a function or a macro and assumes it's a function.  A
 > macro can't be "in effect" if it's file was not loaded "properly".

What I'm saying is that macro expansion during compilation could
trigger a warning if the macro is not loaded properly by the code
which is being compiled. This is a fuzzy idea at best, but I was
thinking of something like:

  0. Maintain a buffer of per-byte-compilation macros

  1. When a new byte compilation starts, flush the buffer of macros.
     Set a flag to indicate that byte compilation is in progress. (I
     would kind of assume that this already happens but I haven't
     checked.)

  2. When byte compilation is taking place and a macro is defined, add
     the macro to the buffer of per-byte-compilation macros with the
     property "defined during compilation".

  3. When byte compilation is taking place and a macro is expanded,
     check in the buffer, and if the macro is not listed as having
     been defined during this compilation, throw a warning.

  4. When byte compilation finishes, the flag to indicate that byte
     compilation is taking place will need to be taken down, of
     course.

This obviously requires already-loaded requires etc to be performed
anew during byte compilation, or some cunning caching of the buffer
which keeps track of when and where a macro was defined (maybe make it
global and permanent per session instead of per-compilation?)

 > The compiler does issue warnings when it encounters an undefined
 > macro/function:
 > While compiling the end of the data in file /home/kevinr/emacs/foo.el:
 >    ** the function bar is not known to be defined.

So now you'd also get something like

  While compiling toplevel forms:
    ** reference to macro `foo' which was not defined during compilation

as a warning that the code may not execute correctly on a system where
the macro is not somehow automatically loaded before the compiled code
will be executed. (As a bonus maybe the `foo' could be clickable so
you could look at the macro's documentation and maybe find out where
it is defined.)

/* era */

-- 
The email address era     the contact information   Just for kicks, imagine
at iki dot fi is heavily  link on my home page at   what it's like to get
spam filtered.  If you    <http://www.iki.fi/era/>  500 pieces of spam for
want to reach me, see     instead.                  each wanted message.





reply via email to

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