GNU bug report logs -
#17623
24.4.50; incorrect example for `apply-partially' in (elisp) `Calling Functions'
Previous Next
Reported by: Drew Adams <drew.adams <at> oracle.com>
Date: Wed, 28 May 2014 23:55:01 UTC
Severity: minor
Found in version 24.4.50
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> I disagree. The paragraph in the manual explains what the arity of the
> function returned by `apply-partially' would be.
>
> Directly following is an example suggesting that (apply-partially '+ 1)
> is equivalent to #'1+ - which obviously contradicts that preceding
> paragraph.
>
> I'm a bit confused that you don't consider this a problem, and also that
> you said there were no concrete suggestions.
I have re-read the paragraph, and I have to say that IMO it is clear as
is written. But I understand that you feel that it is not.
> There were concrete suggestions for improvements. One was to simply
> spell out the function that is constructed. It is only one line, and
> would make the semantics clear.
Instead of going into all that, can't we just find an example where the
arity doesn't present any problems? Any ideas for something like that?
How about zerop?
(defalias 'zerop (apply-partially '= 0)
"Return t if argument is zero.")
But I guess `=' is also N-ary...
> BTW, whenever I posted an example using `apply-partially', Stefan told
> me that it would be more efficient to write out the lambda. That aspect
> could also be covered: when is worth using?
That could be useful to add, I agree.
> Or delete that paragraph, better to say nothing than to confuse readers.
I think it should be kept. Performance is not the only consideration.
(apply-partially #'fun foo bar baz)
(lambda (&rest args) (apply #'fun foo bar baz args))
It's obviously a matter of style but I find the former easier to read
than the latter.
This bug report was last modified 3 years and 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.