GNU bug report logs - #6893
evaluating `'#'(lambda (b) b)8 ; => 8 with `eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'

Previous Next

Package: emacs;

Reported by: MON KEY <monkey <at> sandpframing.com>

Date: Sat, 21 Aug 2010 21:54:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6893 in the body.
You can then email your comments to 6893 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6893; Package emacs. (Sat, 21 Aug 2010 21:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to MON KEY <monkey <at> sandpframing.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 21 Aug 2010 21:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: bug-gnu-emacs <at> gnu.org
Subject: evaluating `'#'(lambda (b) b)8 ; => 8 with `eval-last-sexp' "C-x C-e"
	in `emacs-lisp-mode'
Date: Sat, 21 Aug 2010 17:55:03 -0400
Interactive invocation of `eval-last-sexp' (e.g. "C-x C-e" ) in
Emacs-lisp mode buffer for this form:

 `'#'(lambda (b) b)8
 ;=> 8

`eval-last-sexp' for this makes (some) sense:

 `'#'(lambda (b) b)
 ;=> (quote (function (lambda (b) b)))

And so, presumably the above is equivalent to:

 (eval '(list 'quote '(function (lambda (b) b))))
 ;=> (quote (function (lambda (b) b)))

But what is the equivalent form which would explain the results for
following:

 `'#'(lambda (b) b)8
 ;=> 8

Surely it isn't this:

 (funcall (eval (eval (eval '(list 'quote '(function (lambda (b) b)))))) 8)
 ;=> 8

If it is, then why is eval'ing the same `'#'(lambda (b) b)8 form with
`eval-expression' (e.g. "M-:") met with the message:

 "Trailing garbage following expression"

Likewise, giving `eval-expression' this form lands me in the debugger:

 (`'#'(lambda (b) b) 8)

 ;=> Debugger entered--Lisp error:
     (wrong-number-of-arguments #[(structure) "\301!A\207"
                                  [structure backquote-process] 2 1720176] 2)

Reproducable on 23.2 with emacs -Q

--
/s_P\




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 21 Aug 2010 22:46:03 GMT) Full text and rfc822 format available.

Notification sent to MON KEY <monkey <at> sandpframing.com>:
bug acknowledged by developer. (Sat, 21 Aug 2010 22:46:03 GMT) Full text and rfc822 format available.

Message #10 received at 6893-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: MON KEY <monkey <at> sandpframing.com>
Subject: Re: bug#6893: evaluating `'#'(lambda (b) b)8 ;
	=> 8 with `eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'
Date: Sun, 22 Aug 2010 00:40:17 +0200
> Interactive invocation of `eval-last-sexp' (e.g. "C-x C-e" ) in
> Emacs-lisp mode buffer for this form:

>  `'#'(lambda (b) b)8
>  ;=> 8

C-x C-e doesn't evaluate "the expression on the line" but "the last sexp
before point".
The "last-sexp" is just "8" (try C-M-b to see what it is), so whatever
other sexp you put before won't make any difference.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6893; Package emacs. (Sat, 21 Aug 2010 22:50:03 GMT) Full text and rfc822 format available.

Message #13 received at 6893 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 6893 <at> debbugs.gnu.org
Subject: Re: bug#6893: evaluating `'#'(lambda (b) b)8 ;
	=> 8 with `eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'
Date: Sun, 22 Aug 2010 00:50:15 +0200
MON KEY <monkey <at> sandpframing.com> writes:

> But what is the equivalent form which would explain the results for
> following:
>
>  `'#'(lambda (b) b)8
>  ;=> 8

8

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6893; Package emacs. (Sun, 22 Aug 2010 00:17:01 GMT) Full text and rfc822 format available.

Message #16 received at 6893 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6893 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#6893: evaluating `'#'(lambda (b) b)8 ; => 8 with
	`eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'
Date: Sat, 21 Aug 2010 20:17:22 -0400
On Sat, Aug 21, 2010 at 6:40 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>> Interactive invocation of `eval-last-sexp' (e.g. "C-x C-e" ) in
>> Emacs-lisp mode buffer for this form:
>
>>  `'#'(lambda (b) b)8
>>  ;=> 8
>
> C-x C-e doesn't evaluate "the expression on the line" but "the last sexp
> before point".

OK.

> The "last-sexp" is just "8" (try C-M-b to see what it is), so whatever
> other sexp you put before won't make any difference.

So what about these?

`'#'8
 ;=> (quote (function 8))

 `#'?\x27?\x23
 ;=> (function 39)

Where did 35 go?

>        Stefan

--
/s_P\




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6893; Package emacs. (Tue, 24 Aug 2010 17:27:02 GMT) Full text and rfc822 format available.

Message #19 received at 6893 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 6893 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#6893: evaluating `'#'(lambda (b) b)8 ;
	=> 8 with `eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'
Date: Mon, 23 Aug 2010 00:49:53 +0200
> So what about these?

> `'#'8
>  ;=> (quote (function 8))

What about it?  C-M-b indeed shows that '#'8 is the sexp.

>  `#'?\x27?\x23
>  ;=> (function 39)

> Where did 35 go?

That's a known shortcoming of syntax tables which aren't able to
describe correctly the syntax of Elisp char constants.  But again C-M-b
shows you correctly what C-x C-e considers as "the last sexp".


        Stefan






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6893; Package emacs. (Tue, 24 Aug 2010 20:49:01 GMT) Full text and rfc822 format available.

Message #22 received at 6893 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6893 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#6893: evaluating `'#'(lambda (b) b)8 ; => 8 with
	`eval-last-sexp' "C-x C-e" in `emacs-lisp-mode'
Date: Tue, 24 Aug 2010 16:49:30 -0400
On Sun, Aug 22, 2010 at 6:49 PM, Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
>> So what about these?
>
>> `'#'8
>>  ;=> (quote (function 8))
>
> What about it?  C-M-b indeed shows that '#'8 is the sexp.
>
>>  `#'?\x27?\x23
>>  ;=> (function 39)
>
My point is that with these C M-b:

`'#'

`'

point is skipped back beyond the sexp at point to "M-b:".

Isn't there an implicit list after the last quote created by backquote?

It "feels" like there is with these:

`#1=#1#
;=> (nil)

`','#1=#1#
;=> (quote (nil))

`',#''#1=#1#
;=> (quote (quote (nil)))

`',#','#1=#1#
;=> (quote \,)

`,#','#1=#1#
;=> \,

`',#','nil
;=> (quote \,)

`',#',#1=#1#
;=> (quote \,)

>> Where did 35 go?
>
> That's a known shortcoming of syntax tables which aren't able to
> describe correctly the syntax of Elisp char constants.

Does that affect how the range of "last sexp" is allowed to extend beyond the
beginning-of-line only to find some arbitrary word barier a few lines up?

> But again C-M-b
> shows you correctly what C-x C-e considers as "the last sexp".

Yes well, even w/ C M-b hopping its still not a valid sexp for `eval':

`#'?\x27?\x23
=> (function 39)

(eval (function 39))
;=> 39

(eval `#'?\x27?\x23)
;=> Debugger entered--Lisp error: (wrong-number-of-arguments eval 2)

And besides, theres this anomaly too:

#&8"\377"
;=> "\377" (actually on Emacs 23.2 its => "ÿ")

`#&8"\377"
;=> "\377" (actually on Emacs 23.2 its => "ÿ")

`#&8"\x3fffff"
;=> "\377" (actually on Emacs 23.2 its => "ÿ")

Which would make sense except that _both_ of these manages to fail "correctly":

`'#s

`'#s" "
     !string

=> Debugger entered--Lisp error: (invalid-read-syntax "#")

Despite the fact that C M-b for either of this forms:

`'#s(hash-table size 30 data (key1 val1 key2 300))

#s(hash-table size 30 data (key1 val1 key2 300))

puts point just after "#s".

I understand that the hash-table read syntax has a higher priority because its
newer but the cummulative effect of the various sharpsign quoting/evaluation
rules for the immediate sexp before point feels inconsistently biased when
viewed in the aggregate.

>
>
>        Stefan

--
/s_P\




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 22 Sep 2010 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.