emacs-devel
[Top][All Lists]
Advanced

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

Re: Distinguishing `consp` and `functionp`


From: João Távora
Subject: Re: Distinguishing `consp` and `functionp`
Date: Wed, 31 Jan 2024 10:51:07 +0000

On Wed, Jan 31, 2024 at 3:37 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> >> > Dunno.  SBCL's compiler is pretty good, it propagates types  and warns
> >> > say, when using generic+ instead of must faster fixum+.
> >> Knowing "this is a function" isn't terribly better than "this is
> >> either a function or a cons cell starting with `lambda`": it will rarely
> >> let you turn a generic+ into a fixnum+.
> > Isn't knowing "this is a function" a prerequisite for proving e.g.
> > "this is a function returning a fixnum"?
>
> Maybe it's a prerequisite, but it's pretty damn far from sufficient: if
> you're in a position to know that it returns a fixnum, then you
> most likely won't need `funcall` to tell you that it's a function.

Not sure I follow, but fair enough.  Big or small, whatever benefit
it brings is certainly more than the benefits the the current
situation brings which is 0.

...apart from working with legacy code, of course.  So as I said I
really think you should leave functionp returning t for a good
while and warn about the funcall.  I think that'll make the numbers
of these things dwindle.  It's a fairly common error, not only
in user code [1,2], and the warning would have just told the users
what we end up telling them.

In fact, this is probably so common that the warning should have
some kind of anti-spam safeguard, like not warning twice for the
same object, or just limit the number of warnings per session to 5
or something.

> There are much lower hanging fruits.

By all means go grab them :-)

João

[1] https://github.com/joaotavora/eglot/pull/626#issuecomment-786606685
[2] https://github.com/joaotavora/eglot/discussions/691#discussioncomment-719357



reply via email to

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