[Top][All Lists]

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

Re: cc-vars.el

From: Dave Love
Subject: Re: cc-vars.el
Date: 19 Nov 2002 16:55:47 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Martin Stjernholm <address@hidden> writes:

> True, but it's more valid within different versions of the same
> branch, e.g. between Emacs 20 and 21,

You definitely can't rely on Emacs 21 byte code running in Emacs 20.

> and even more so between minor versions.

There's no guarantee of that either, particularly if macro expansions
change to use new features.

> I had at one point a simple macro system that tested all
> this at compile time and made completely tailored byte code, and I got
> a complaint from a user then.

I don't understand that.  I wouldn't worry about details of the
compiled code.

> The only way to avoid compiler warnings cleanly (in some sense) is to
> do the tests with macros at compile time,

I don't think that's true.  Definitely not if compilation is done in
batch, file-by-file so that stuff in `eval-when-compile' doesn't
affect other compilations.  

> Don't you rather mean code like this?
>     (if (fboundp 'fred)
>         (fred ...))

Yes, sorry.

> It'd be cool if the compiler did enough flow analysis to cope with
> that, but it might be hard to get it to work well, and if it doesn't
> work well then I'd prefer to have the possibility to control the
> warnings explicitly with some pragma-like system.

It doesn't do data-flow analysis, and doesn't need to in order to do
this sort of thing usefully.  It was a simple change to the function
that compiles `if'.

> An interesting angle is if something like the following can be used
> (although I'd consider this too a workaround rather than a solution):
>     (if (boundp 'fido)
>         (symbol-value 'fido))
>     (if (fboundp 'fred)
>         (funcall 'fred ...))
> Someone with insight in the inner workings of the compiler can perhaps
> advice on how effectively it manages to optimize such things.

(equal (byte-compile (lambda () (if (fboundp 'fred) (funcall 'fred))))
       (byte-compile (lambda () (if (fboundp 'fred) (fred)))))
  => t

I think CL used such a trick, but it's not (now) effective.

> Anyway, this is besides the point regarding cc-bytecomp, since that
> one is necessary to keep it working and compiling without warnings on
> both Emacs and XEmacs.

I don't see what the real difference is between cc-mode and Gnus in
this respect, but then I'm not maintaining cc-mode.

reply via email to

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