emacs-devel
[Top][All Lists]
Advanced

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

Re: Can the byte-compiler check whether functions passed by name are def


From: Stefan Monnier
Subject: Re: Can the byte-compiler check whether functions passed by name are defined?
Date: Thu, 01 Aug 2013 16:31:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>>> 1. Has to be done, though maybe through a macro, for every higher-order
>>> function.
>> Note that macroexp.el already has special handling for the main
>> higher-order functions (to warn about '(lambda ...)).  So it could be
>> implemented there.
> I presume the list of “main higher-order” functions is hard-coded
> then, isn't it?

Currently, yes.  It could be moved from macroexp.el's main loop to
a bunch of compiler-macros (the code predates the introduction of
compiler macros in core Elisp), if needed.

> Is there a symbol property or "declare" form to mark specific
> arguments as function arguments, to have the same warnings for higher
> order functions from 3rd party libraries, too?  Similar to how
> "docstring" arguments for macros are handled?

No, and I think it would be overkill.  But 3rd party can also use
a compiler-macro to turn the ' into a #'.

The approach I use for '(lambda ...) is to emit warnings in the common
cases, so that coders will slowly learn, which then benefits all cases.

For '(lambda ...) that works well, because removing the ' (or using #')
is often useful (making it possible to byte-compile the code, or using
lexically bound vars), but for single quoted symbols, the benefit is
a lot less clear ("turn 'foo into #'foo to get rid of the silly new
warning" only to then get another warning because the compiler doesn't
understand that `foo' will very much exist by the time we try to call it).


        Stefan



reply via email to

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