unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15538: 24.3; Incorrect Expansion of Nested Backquote
@ 2013-10-06 11:23 白井 彰
  2013-10-08  4:30 ` Stefan Monnier
  2013-10-28 22:47 ` Nathan Trapuzzano
  0 siblings, 2 replies; 3+ messages in thread
From: 白井 彰 @ 2013-10-06 11:23 UTC (permalink / raw)
  To: 15538; +Cc: okshirai

The expansion of nested backquote like

``(,,@q)

or

``(,@,@q)

is incorrect.

Please see the following results.


; The followings are from CLtL2 Appendix C. Backquote

(require 'cl-lib)
cl-lib


(setq q '(r s))
(r s)

(defun r (x) (cl-reduce #'* x))
r

(setq r '(3 5))
(3 5)

(setq s '(4 6))
(4 6)


``(,,q)
(\` ((\, (r s))))
(24)                                    ; Correct

``(,@,q)
(\` ((\,@ (r s))))
24                                      ; Correct

``(,,@q)
(\` ((\, r s)))
((3 5))                                 ; Incorrect: This should be  
((3 5) (4 6))

``(,@,@q)
(\` ((\,@ r s)))
(3 5)                                   ; Incorrect: This should be (3  
5 4 6)


(setq x '(b c))
(b c)

(setq y '(a b))
(a b)

(setq p '(cl-union x y))
(cl-union x y)

(setq q '((cl-union x y) (list 'sqrt 9)))
((cl-union x y) (list (quote sqrt) 9))

(setq r '(cl-union x y))
(cl-union x y)

(setq s '((cl-union x y)))
((cl-union x y))


``(foo ,,p)
(\` (foo (\, (cl-union x y))))
(foo (a b c))                           ; Correct

``(foo ,,@q)
(\` (foo (\, (cl-union x y) (list (quote sqrt) 9))))
(foo (a b c))                           ; Incorrect: This should be  
(foo (a b c) (sqrt 9))

``(foo ,',r)
(\` (foo (\, (quote (cl-union x y)))))
(foo (cl-union x y))                    ; Correct

``(foo ,',@s)
(\` (foo (\, (quote (cl-union x y)))))
(foo (cl-union x y))                    ; Correct

``(foo ,@,p)
(\` (foo (\,@ (cl-union x y))))
(foo a b c)                             ; Correct

``(foo ,@,@q)
(\` (foo (\,@ (cl-union x y) (list (quote sqrt) 9))))
(foo a b c)                             ; Incorrect: This should be  
(foo a b c sqrt 9)

``(foo ,@',r)
(\` (foo (\,@ (quote (cl-union x y)))))
(foo cl-union x y)                      ; Correct

``(foo ,@',@s)
(\` (foo (\,@ (quote (cl-union x y)))))
(foo cl-union x y)                      ; Correct


In GNU Emacs 24.3.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
  of 2013-04-30 on mini2.local
Windowing system distributor `Apple', version 10.3.949
Configured using:
  `configure '--with-ns' '--without-x''

Important settings:
   value of $LANG: ja_JP.ujis
   locale-coding-system: japanese-iso-8bit-unix
   default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
<escape> x r e p o r t - e m a c s - b u g <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date japan-util tooltip ediff-hook
vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)






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

* bug#15538: 24.3; Incorrect Expansion of Nested Backquote
  2013-10-06 11:23 bug#15538: 24.3; Incorrect Expansion of Nested Backquote 白井 彰
@ 2013-10-08  4:30 ` Stefan Monnier
  2013-10-28 22:47 ` Nathan Trapuzzano
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-10-08  4:30 UTC (permalink / raw)
  To: 白井 彰; +Cc: 15538

> ``(,,@q)
> (\` ((\, r s)))
> ((3 5))                                 ; Incorrect: This should be ((3 5)
> (4 6))

Indeed, it's incorrect, but I think the intention of the current code is
to consider the above expression as invalid, so the error is to return
a value at step 2 (ignoring the second argument `s' to the unquote)
instead of signalling an error.

If you really want that result, you can do

 ``(,@(list ,@q))


> ``(,@,@q)

And here, you'd have to use

  ``(,@(append ,@q))

I installed a patch into trunk which catches the above problems and
signals an error if/when encountering such situations.
Thank you,


        Stefan





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

* bug#15538: 24.3; Incorrect Expansion of Nested Backquote
  2013-10-06 11:23 bug#15538: 24.3; Incorrect Expansion of Nested Backquote 白井 彰
  2013-10-08  4:30 ` Stefan Monnier
@ 2013-10-28 22:47 ` Nathan Trapuzzano
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Trapuzzano @ 2013-10-28 22:47 UTC (permalink / raw)
  To: 15538

Stefan,

Is there any reason why double unquote/unquote-splicing can't work in
Emacs?  A comment in your commit seems to suggest it's doable, so may I
ask why you decided not to implement it?  I suspect many macro-writing
macros would be much more readable if they could be written as they
often are in Common Lisp.

Nathan





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

end of thread, other threads:[~2013-10-28 22:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06 11:23 bug#15538: 24.3; Incorrect Expansion of Nested Backquote 白井 彰
2013-10-08  4:30 ` Stefan Monnier
2013-10-28 22:47 ` Nathan Trapuzzano

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