unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* What's up with apply-partially?
@ 2015-01-23 22:14 David Kastrup
  2015-01-24  3:05 ` Leo Liu
  2015-01-24  3:53 ` What's up with apply-partially? Artur Malabarba
  0 siblings, 2 replies; 11+ messages in thread
From: David Kastrup @ 2015-01-23 22:14 UTC (permalink / raw)
  To: emacs-devel


The original definition of apply-partially in subr.el by Eli in 2008 has
been

(defun apply-partially (fun &rest args)
  "Return a function that is a partial application of FUN to ARGS.
ARGS is a list of the first N arguments to pass to FUN.
The result is a new function which does the same as FUN, except that
the first N arguments are fixed at the values with which this function
was called."
  (lexical-let ((fun fun) (args1 args))
    (lambda (&rest args2) (apply fun (append args1 args2)))))

The current definition by Stefan, however, is
(defun apply-partially (fun &rest args)
  "Return a function that is a partial application of FUN to ARGS.
ARGS is a list of the first N arguments to pass to FUN.
The result is a new function which does the same as FUN, except that
the first N arguments are fixed at the values with which this function
was called."
  `(closure (t) (&rest args)
            (apply ',fun ,@(mapcar (lambda (arg) `',arg) args) args)))

Now subr.el has lexical-bind set.  It seems quite pointless to return
some unevaluated quoted list here (apply-partially is not a macro but a
function!).

So why not just

(defun apply-partially (fun &rest args)
  (lambda (&rest args2) (apply fun (append args args2))))

Where is the point in the complicated redefinition that returns a
basically uncompiled function?  Why not just take Eli's definition and
simplify it in line with lexical-binding now being set?

I don't understand the point of the change.  Lexical bindings should
have made this function more straightforward.  Instead it has become
more complex and unevaluated.  And it's not like describe-function even
knows `closure', as opposed to `lambda'.  So it's become inscrutable as
well.

-- 
David Kastrup



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

end of thread, other threads:[~2015-02-05 17:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-23 22:14 What's up with apply-partially? David Kastrup
2015-01-24  3:05 ` Leo Liu
2015-01-24  5:01   ` Stefan Monnier
2015-01-24  8:54     ` David Kastrup
2015-01-25 14:32       ` Stefan Monnier
2015-01-25 19:45         ` [PATCH] Let apply-partially make use of lexical binding in subr.el David Kastrup
2015-01-27 16:12           ` David Kastrup
2015-01-29 15:01             ` Stefan Monnier
2015-01-29 15:17               ` David Kastrup
2015-02-05 17:55                 ` David Kastrup
2015-01-24  3:53 ` What's up with apply-partially? Artur Malabarba

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).