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: Klaus-Dieter Bauer
Subject: Re: Can the byte-compiler check whether functions passed by name are defined?
Date: Wed, 7 Aug 2013 13:27:50 +0200

2013/8/5 Klaus-Dieter Bauer <address@hidden>:
> 2013/8/5 Stefan Monnier <address@hidden>:
>>>     (mapcar (if flag 'f1 'f2) list)
>>>     => (mapcar (if flag #'f1 #'f2) list)
>>
>> No, I definitely don't want to get into such fanciness.
>> But I do want compiler warnings if the coder writes
>>
>>      (mapcar (if flag #'f1 #'f2) list)
>>
>> and `f1' or `f2' are unknown.
>
> My code does that and indeed that was, what I first implemented. I
> then added the second check, where (quote f1) is handled for functions
> known to be higher-order.
>
>>> Shouldn't the markup for user-written functions be a bit easier?
>>
>> I'm not too worried about it, no.  We should instead aim to teach people
>> to write #'foo instead of 'foo.
>
> I am not sure about that... On the one hand, I see your point, since
> consistently writing #'function is better for the byte compiler, as in
> the (if flag #'f1 #'f2) form; If #'f1 is the standard method people
> will write (if flag 'f1 'f2) and not get a warning.
>
> On the other hand though, subjectively, #'f1 is a huge deal more
> visual clutter and somewhat awkward to type (on a German keyboard at
> least). Might be just a training effect, but I also feel that the
> hash-quote sequence moves the attention away from the function name,
> while 'f1 does not (or #f1, '#f1 for that matter, but those are not
> elisp).
>
>   - Klaus

Made a new version of the patch, were warnings are emitted for
registered function arguments. Downside: While educational towards
#'FUNCTION notation, it will result in a good deal of warnings all
across even included code. I'd say this results in a risk of people
ignoring warnings alltogether, including those that likely point out
actual errors such as "reference to free variable". For bytecomp.el
alone it results in 22 warnings!

Advantage would be that using such aggressive "reeducation" the the
declare form would be mostly unnecessary.

  - Klaus

Attachment: bytecomp.el.patch-2
Description: Binary data


reply via email to

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