unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: bytecomp warning for CL functions
       [not found] <rzqhejse35l.fsf@albion.dl.ac.uk>
@ 2002-06-25 23:32 ` Richard Stallman
  2002-06-26 14:10   ` Stefan Monnier
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2002-06-25 23:32 UTC (permalink / raw)
  Cc: emacs-devel

That is a good idea--Eli, would you please install it?

I think it would be even better if these warnings were issued by default
whenever the file does not include cl.  Does anyone see a reason not
to do that?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-06-25 23:32 ` bytecomp warning for CL functions Richard Stallman
@ 2002-06-26 14:10   ` Stefan Monnier
  2002-07-01 18:11     ` Dave Love
                       ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Stefan Monnier @ 2002-06-26 14:10 UTC (permalink / raw)
  Cc: d.love, emacs-devel

> That is a good idea--Eli, would you please install it?
> 
> I think it would be even better if these warnings were issued by default
> whenever the file does not include cl.  Does anyone see a reason not
> to do that?

Could someone explain to me what this really does ?
I had installed a hack that tries to notice when you call a function
that will not be available at runtime (because the library
was loaded via (eval-when-compile (require 'LIB)) as is done for CL).

It had a bug that I just fixed so it should be a bit more useful now.

In what way does Dave's code differ ?
I notice for example that it warns about code that uses `values' but
since the CVS has replaced the defvalias with a defsubst for `values',
a call to `values' gets replaced during byte-compilation so that
it works just fine even without using CL at runtime.

Admittedly, my hack is just that: a hack.  And it's not reliable.
But it is more genric and covers more cases.  So my question is:
which cases does Dave's code cover that mine doesn't.

What I'm trying to figue out is if there is a way to get the benefits
of Dave's code without having to hard-code any particular list
of functions.


	Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-06-26 14:10   ` Stefan Monnier
@ 2002-07-01 18:11     ` Dave Love
  2002-07-02 19:45       ` Richard Stallman
  2002-07-08 18:19     ` Richard Stallman
  2002-07-08 18:20     ` Richard Stallman
  2 siblings, 1 reply; 22+ messages in thread
From: Dave Love @ 2002-07-01 18:11 UTC (permalink / raw)
  Cc: Richard Stallman, emacs-devel

"Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:

> Could someone explain to me what this really does ?

It detects all (I hope) use of cl functions in the compiled code to
help me debug it.

> I had installed a hack that tries to notice when you call a function
> that will not be available at runtime (because the library
> was loaded via (eval-when-compile (require 'LIB)) as is done for CL).

The cases of interest are when that isn't done, or when you're in a
session that's already loaded it for some reason (e.g. Debian with
various Emacs packages installed) or when there's an explicit autoload
defined for a cl function, &c.  (Real examples.)

> I notice for example that it warns about code that uses `values' but
> since the CVS has replaced the defvalias with a defsubst for `values',
> a call to `values' gets replaced during byte-compilation so that
> it works just fine even without using CL at runtime.

The warning would be useful regardless, if you're trying to make stuff
run in 21.2.  In principle it would also list things problematic in
Emacs 20, but I don't currently need that.

> What I'm trying to figue out is if there is a way to get the benefits
> of Dave's code without having to hard-code any particular list
> of functions.

Sure.  You'd have to check the indirections of aliases to see if they
contained anything defined in the cl files.  Obviously you could
generalize it to deal with packages other than cl, but I can't think
of any for which that would be useful.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-01 18:11     ` Dave Love
@ 2002-07-02 19:45       ` Richard Stallman
  2002-07-03  7:21         ` Juanma Barranquero
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2002-07-02 19:45 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

    > What I'm trying to figue out is if there is a way to get the benefits
    > of Dave's code without having to hard-code any particular list
    > of functions.

That ought to be a small and simple generalization, if we ever want to
make it.  I don't see a need to make it now.  I will install this
code, together with some changes so that these warnings are enabled
automatically whenever the file being compiled does not do (require
'cl) at run time.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-02 19:45       ` Richard Stallman
@ 2002-07-03  7:21         ` Juanma Barranquero
  2002-07-08 18:20           ` Richard Stallman
  2002-07-18 18:48           ` Dave Love
  0 siblings, 2 replies; 22+ messages in thread
From: Juanma Barranquero @ 2002-07-03  7:21 UTC (permalink / raw)
  Cc: d.love, monnier+gnu/emacs, emacs-devel

On Tue, 2 Jul 2002 13:45:59 -0600 (MDT), Richard Stallman <rms@gnu.org> wrote:

> I will install this
> code, together with some changes so that these warnings are enabled
> automatically whenever the file being compiled does not do (require
> 'cl) at run time.

So now, having that in .emacs:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'cl)

(defvar lk-faces-regexp-history nil)

(defadvice list-faces-display (around lk-faces-regexp (arg) activate compile preactivate)
  "If ARG is non-nil, prompt for a regexp and list only
those faces matching the regexp."
  (interactive "P")
  (if arg
      (let* ((regexp (read-string "Faces (regexp): " nil 'lk-faces-regexp-history nil t))
             (faces (if (string= regexp "")
                        (face-list)
                      (delete-if-not #'(lambda (face)
                                         (string-match regexp (symbol-name face)))
                                     (face-list)))))
        (if faces
            (flet ((face-list () faces))
              ad-do-it)
          (message "No faces matching \"%s\"" regexp)))
    ad-do-it))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


causes a warning at startup time:

  warning: Function `delete-if-not' from cl package called at runtime

:(


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-06-26 14:10   ` Stefan Monnier
  2002-07-01 18:11     ` Dave Love
@ 2002-07-08 18:19     ` Richard Stallman
  2002-07-18 18:53       ` Dave Love
  2002-07-08 18:20     ` Richard Stallman
  2 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2002-07-08 18:19 UTC (permalink / raw)
  Cc: d.love, emacs-devel

    I had installed a hack that tries to notice when you call a function
    that will not be available at runtime (because the library
    was loaded via (eval-when-compile (require 'LIB)) as is done for CL).

If you can make your code superior to Dave's code that I installed and
then built on, please go ahead and put it in.  His code has a list of
specific CL functions in it, and also checks the function name.
If your code check both kinds of cases and handles both properly, it probably
does everything right.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-06-26 14:10   ` Stefan Monnier
  2002-07-01 18:11     ` Dave Love
  2002-07-08 18:19     ` Richard Stallman
@ 2002-07-08 18:20     ` Richard Stallman
  2002-07-08 19:30       ` Luc Teirlinck
  2 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2002-07-08 18:20 UTC (permalink / raw)
  Cc: d.love, emacs-devel

Dave's warning code checks for multiple-value-call,
a name that I remember vaguely from long ago.
However, loading cl.el does not define multiple-value-call.
Is that absence a bug?  If so, would someone like to define it?
(Or tell me what it is supposed to do?)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-03  7:21         ` Juanma Barranquero
@ 2002-07-08 18:20           ` Richard Stallman
  2002-07-18 18:48           ` Dave Love
  1 sibling, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-08 18:20 UTC (permalink / raw)
  Cc: d.love, monnier+gnu/emacs, emacs-devel

    (require 'cl)

    (defvar lk-faces-regexp-history nil)

    (defadvice list-faces-display (around lk-faces-regexp (arg) activate compile preactivate)
      "If ARG is non-nil, prompt for a regexp and list only
    those faces matching the regexp."
      (interactive "P")

I fixed this.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-08 18:20     ` Richard Stallman
@ 2002-07-08 19:30       ` Luc Teirlinck
  2002-07-09 18:51         ` Richard Stallman
  2002-07-18 18:34         ` Dave Love
  0 siblings, 2 replies; 22+ messages in thread
From: Luc Teirlinck @ 2002-07-08 19:30 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, d.love, emacs-devel

Richard Stallman wrote:
   
   Dave's warning code checks for multiple-value-call,
   a name that I remember vaguely from long ago.
   However, loading cl.el does not define multiple-value-call.
   Is that absence a bug?  If so, would someone like to define it?
   (Or tell me what it is supposed to do?)

In Emacs21.2.90 loading cl seems to define multiple-value-call.
Output of C-h f:

multiple-value-call is an alias for `apply' in `cl'.
[Missing arglist.  Please make a bug report.]

Call FUNCTION with our remaining args, using our last arg as list of
args.
Then return the value FUNCTION returns.
Thus, (apply '+ 1 2 '(3 4)) returns 10.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-08 19:30       ` Luc Teirlinck
@ 2002-07-09 18:51         ` Richard Stallman
  2002-07-18 18:34         ` Dave Love
  1 sibling, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-09 18:51 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, d.love, emacs-devel

    In Emacs21.2.90 loading cl seems to define multiple-value-call.

The comment on that defalias shows it is not entirely correct.
It is better than nothing, so I will put it back in.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-08 19:30       ` Luc Teirlinck
  2002-07-09 18:51         ` Richard Stallman
@ 2002-07-18 18:34         ` Dave Love
  2002-07-19 16:54           ` Richard Stallman
  1 sibling, 1 reply; 22+ messages in thread
From: Dave Love @ 2002-07-18 18:34 UTC (permalink / raw)
  Cc: rms, monnier+gnu/emacs, emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> multiple-value-call is an alias for `apply' in `cl'.
> [Missing arglist.  Please make a bug report.]

I fixed that.  I don't know if there's any problem with the code on
the trunk, which I don't understand.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-03  7:21         ` Juanma Barranquero
  2002-07-08 18:20           ` Richard Stallman
@ 2002-07-18 18:48           ` Dave Love
  2002-07-19  6:09             ` Juanma Barranquero
  2002-07-19 16:54             ` Richard Stallman
  1 sibling, 2 replies; 22+ messages in thread
From: Dave Love @ 2002-07-18 18:48 UTC (permalink / raw)
  Cc: rms, monnier+gnu/emacs, emacs-devel

> causes a warning at startup time:
> 
>   warning: Function `delete-if-not' from cl package called at runtime

Comments:

1. The warning is being issued correctly.

2. It's not a good idea to load cl in .emacs -- you can fail to spot
   problems, apart from the bloat.

3. You can turn off implicit compilation by defadvice.

4. defadvice should normally be avoided, apart from the bloat.  If a
   modification you want to make with it is useful, it normally
   indicates the lack of a hook.  I'd just copy the function and
   modify it to avoid sucking in advice in a case like that.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-08 18:19     ` Richard Stallman
@ 2002-07-18 18:53       ` Dave Love
  2002-07-19 16:54         ` Richard Stallman
  0 siblings, 1 reply; 22+ messages in thread
From: Dave Love @ 2002-07-18 18:53 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     I had installed a hack that tries to notice when you call a function
>     that will not be available at runtime (because the library
>     was loaded via (eval-when-compile (require 'LIB)) as is done for CL).
> 
> If you can make your code superior to Dave's code that I installed and
> then built on, please go ahead and put it in.

As far as I know, they're different things.  My code was specifically
testing CL stuff, even if it would be present at runtime, whereas
Stefan's would check for problems with functions not being available
at runtime generally.  (It never seemed to warn me usefully anyway,
but presumably that was because it was buggy.)

> His code has a list of specific CL functions in it,

That's only a few that are aliases and would otherwise escape.

> and also checks the function name.
> If your code check both kinds of cases and handles both properly, it probably
> does everything right.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-18 18:48           ` Dave Love
@ 2002-07-19  6:09             ` Juanma Barranquero
  2002-07-19 16:54             ` Richard Stallman
  1 sibling, 0 replies; 22+ messages in thread
From: Juanma Barranquero @ 2002-07-19  6:09 UTC (permalink / raw)
  Cc: emacs-devel

On 18 Jul 2002 19:48:38 +0100, Dave Love <d.love@dl.ac.uk> wrote:

> Comments:
> 
> 1. The warning is being issued correctly.

Perhaps, but if defadvice has been patched to stop it, that must mean
that it was useless and annoying nonetheless.

> 2. It's not a good idea to load cl in .emacs -- you can fail to spot
>    problems, apart from the bloat.

Oh, come on. I happen to *like* cl and don't consider it a bloat.
Obviously it is a matter of taste, but I feel vaguely offensive that you
answer to a comment about a newly introduced warning saying what I
should do with my .emacs.

As two recent posters on gnu.emacs.help have said:

"You don't need (require 'cl) though I expect like me you have it in
your .emacs file somewhere so you never quite know whether you need it
or not." (Rob Thorpe)

"The proper place for '(require 'cl)' is in your .emacs file, at the top
level :)" (Marco Antoniotti)

> 3. You can turn off implicit compilation by defadvice.

Yes.

> 4. defadvice should normally be avoided, apart from the bloat.

Again, I don't consider it bloat. And I don't know why should I avoid it.
AFAICS there's a policy of avoiding it in modules, but for my own
customizations? What is advice.el intended for, if not that?

> If a modification you want to make with it is useful, it normally
> indicates the lack of a hook.  I'd just copy the function and
> modify it to avoid sucking in advice in a case like that.

Are you suggesting that would be better to copy the eight functions I'm
currently advising to my .emacs and then manually monitoring if they
ever change in their original sources?

Excuse me, but I think you're taking your likes or dislikes as a measure
of what's good for another user...


                                                           /L/e/k/t/u

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-18 18:34         ` Dave Love
@ 2002-07-19 16:54           ` Richard Stallman
  2002-07-22 22:15             ` Dave Love
  0 siblings, 1 reply; 22+ messages in thread
From: Richard Stallman @ 2002-07-19 16:54 UTC (permalink / raw)
  Cc: teirllm, monnier+gnu/emacs, emacs-devel

    I fixed that.  I don't know if there's any problem with the code on
    the trunk, which I don't understand.

Normally "I fixed that" means you installed a fix in the trunk,
but it sounds like you're saying that is not what you did.
Where did you install the fix that you made?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-18 18:48           ` Dave Love
  2002-07-19  6:09             ` Juanma Barranquero
@ 2002-07-19 16:54             ` Richard Stallman
  1 sibling, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-19 16:54 UTC (permalink / raw)
  Cc: lektu, monnier+gnu/emacs, emacs-devel

    > causes a warning at startup time:
    > 
    >   warning: Function `delete-if-not' from cl package called at runtime

You can turn off these warnings by setting the variable
byte-compile-error-on-warn to the list of warning types
that you do want.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-18 18:53       ` Dave Love
@ 2002-07-19 16:54         ` Richard Stallman
  2002-07-19 17:49           ` Stefan Monnier
  2002-07-29 22:46           ` Dave Love
  0 siblings, 2 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-19 16:54 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

    As far as I know, they're different things.  My code was specifically
    testing CL stuff, even if it would be present at runtime, whereas
    Stefan's would check for problems with functions not being available
    at runtime generally.

The way I changed your code, it warns about run-time calls to CL
functions from a file that doesn't necessarily load CL at run time.
Stefan, in your code, is the criterion the same: call to a function
in file X, from another file Y that doesn't necessarily load X at run time?

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-19 16:54         ` Richard Stallman
@ 2002-07-19 17:49           ` Stefan Monnier
  2002-07-20  0:35             ` Richard Stallman
  2002-07-29 22:46           ` Dave Love
  1 sibling, 1 reply; 22+ messages in thread
From: Stefan Monnier @ 2002-07-19 17:49 UTC (permalink / raw)
  Cc: d.love, monnier+gnu/emacs, emacs-devel

>     As far as I know, they're different things.  My code was specifically
>     testing CL stuff, even if it would be present at runtime, whereas
>     Stefan's would check for problems with functions not being available
>     at runtime generally.
> 
> The way I changed your code, it warns about run-time calls to CL
> functions from a file that doesn't necessarily load CL at run time.
> Stefan, in your code, is the criterion the same: call to a function
> in file X, from another file Y that doesn't necessarily load X at run time?

Mostly, but the devil is in the details.
It complaints when:
the file calls F and F is known to exist during compilation but
not at runtime (because it was made available through (eval-when-compile
(require 'foo))).

But it doesn't work so well if `bar' gets loaded by foo.elc
(and is thus marked as "not available at runtime") but is later
on required explicitly.  I don't check this case.

Also, if `foo' was already loaded when the compilation started,
the results depend on how it was loaded, so it doesn't work
too well with recompile-directory unless the file is either always
required directly or always required through `eval-when-compile'.


	Stefan

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-19 17:49           ` Stefan Monnier
@ 2002-07-20  0:35             ` Richard Stallman
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-20  0:35 UTC (permalink / raw)
  Cc: d.love, monnier+gnu/emacs, emacs-devel

    But it doesn't work so well if `bar' gets loaded by foo.elc
    (and is thus marked as "not available at runtime") but is later
    on required explicitly.  I don't check this case.

I am having trouble understanding what the scenario is here.

    Also, if `foo' was already loaded when the compilation started,
    the results depend on how it was loaded, so it doesn't work
    too well with recompile-directory unless the file is either always
    required directly or always required through `eval-when-compile'.

This is a very important case, as regards CL.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-19 16:54           ` Richard Stallman
@ 2002-07-22 22:15             ` Dave Love
  0 siblings, 0 replies; 22+ messages in thread
From: Dave Love @ 2002-07-22 22:15 UTC (permalink / raw)
  Cc: teirllm, monnier+gnu/emacs, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> Where did you install the fix that you made?

On the release branch, where the problem showed up.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-19 16:54         ` Richard Stallman
  2002-07-19 17:49           ` Stefan Monnier
@ 2002-07-29 22:46           ` Dave Love
  2002-07-30 18:46             ` Richard Stallman
  1 sibling, 1 reply; 22+ messages in thread
From: Dave Love @ 2002-07-29 22:46 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> The way I changed your code, it warns about run-time calls to CL
> functions from a file that doesn't necessarily load CL at run time.

I don't understand.  Surely my change did that anyhow?  It just looked
at the expanded, optimized forms.

Not that I care, as long as you can get useful warnings.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: bytecomp warning for CL functions
  2002-07-29 22:46           ` Dave Love
@ 2002-07-30 18:46             ` Richard Stallman
  0 siblings, 0 replies; 22+ messages in thread
From: Richard Stallman @ 2002-07-30 18:46 UTC (permalink / raw)
  Cc: monnier+gnu/emacs, emacs-devel

    > The way I changed your code, it warns about run-time calls to CL
    > functions from a file that doesn't necessarily load CL at run time.

    I don't understand.  Surely my change did that anyhow?  It just looked
    at the expanded, optimized forms.

No, your code had nothing to test whether the compiled file would load 
cl when loaded.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2002-07-30 18:46 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <rzqhejse35l.fsf@albion.dl.ac.uk>
2002-06-25 23:32 ` bytecomp warning for CL functions Richard Stallman
2002-06-26 14:10   ` Stefan Monnier
2002-07-01 18:11     ` Dave Love
2002-07-02 19:45       ` Richard Stallman
2002-07-03  7:21         ` Juanma Barranquero
2002-07-08 18:20           ` Richard Stallman
2002-07-18 18:48           ` Dave Love
2002-07-19  6:09             ` Juanma Barranquero
2002-07-19 16:54             ` Richard Stallman
2002-07-08 18:19     ` Richard Stallman
2002-07-18 18:53       ` Dave Love
2002-07-19 16:54         ` Richard Stallman
2002-07-19 17:49           ` Stefan Monnier
2002-07-20  0:35             ` Richard Stallman
2002-07-29 22:46           ` Dave Love
2002-07-30 18:46             ` Richard Stallman
2002-07-08 18:20     ` Richard Stallman
2002-07-08 19:30       ` Luc Teirlinck
2002-07-09 18:51         ` Richard Stallman
2002-07-18 18:34         ` Dave Love
2002-07-19 16:54           ` Richard Stallman
2002-07-22 22:15             ` Dave Love

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).