GNU bug report logs -
#25280
25.1; define-inline doesn't support &rest
Previous Next
Reported by: Leo Liu <sdl.web <at> gmail.com>
Date: Tue, 27 Dec 2016 02:43:01 UTC
Severity: normal
Found in version 25.1
Fixed in version 25.2
Done: Leo Liu <sdl.web <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
>> (let ((x 1) (y 2)) (princ (rest x y))) ; B
>> So A prints [1 2] and B [x y] i.e. x y is not eval'd. thoughts?
> Hmm... indeed... and it breaks down even with (rest (+ x 1) y).
Wait, I was confused: `xs` is a list of expressions, so of course ', is
not the right way to place it in there. To turn it into an expression
that evaluates to a list of values, you generally want (list . ,xs):
(define-inline sm-foo (&rest xs)
(inline-letevals xs (inline-quote (apply #'vector (list . ,xs)))))
and I think this works correctly.
OTOH it's not as efficient as we'd like. The better way to write it is:
(define-inline sm-foo (&rest xs)
(inline-letevals xs (inline-quote (vector . ,xs))))
but I now see that this is not handled properly in the case the function
is not inlined. More specifically, the `sm-foo` function gets defined as:
(lambda (&rest xs) (apply vector xs))
where the `vector` failed to be quoted with #'.
I installed the patch below into `master` which should fix it.
Stefan
diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el
index 058c56c3b49..5ceb0d9ed29 100644
--- a/lisp/emacs-lisp/inline.el
+++ b/lisp/emacs-lisp/inline.el
@@ -191,9 +191,9 @@ After VARS is handled, BODY is evaluated in the new environment."
(while (and (consp exp) (not (eq '\, (car exp))))
(push (inline--dont-quote (pop exp)) args))
(setq args (nreverse args))
- (if exp
- `(apply ,@args ,(inline--dont-quote exp))
- args)))
+ (if (null exp)
+ args
+ `(apply #',(car args) ,@(cdr args) ,(inline--dont-quote exp)))))
(_ exp)))
(defun inline--do-leteval (var-exp &rest body)
This bug report was last modified 8 years and 207 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.