unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* What happens when I evaluate the call the second time?
@ 2007-07-02 22:20 Eric Lilja
  2007-07-03  9:45 ` Mathias Dahl
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Lilja @ 2007-07-02 22:20 UTC (permalink / raw)
  To: emacs-devel

Hello, I've just started with lisp programming and I encountered 
something I thought was odd.

Using GNU Emacs 22.0.990.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on 
MINDCOOLER

Starting with -Q

In the scratch buffer I write

(defun average (x y)
   (/ (+ x y) 2)
)

(average 2 3)

First C-x C-e after the function, then twice after calling it. The 
output is:
average
2
2 (#o2, #x2, ?\C-b)

Now what's the (#o2, #x2, ?\C-b) stuff?

- Eric

PS. I notice that the output is 2 and not 2.5, I guess the output gets 
truncated to an integer (the decimal part is discarded).

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

* Re: What happens when I evaluate the call the second time?
  2007-07-02 22:20 What happens when I evaluate the call the second time? Eric Lilja
@ 2007-07-03  9:45 ` Mathias Dahl
  2007-07-03 10:00   ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Dahl @ 2007-07-03  9:45 UTC (permalink / raw)
  To: Eric Lilja; +Cc: emacs-devel

> First C-x C-e after the function, then twice after calling it. The
> output is:
> average
> 2
> 2 (#o2, #x2, ?\C-b)
>
> Now what's the (#o2, #x2, ?\C-b) stuff?

Different ways to express 2 I think. What I find strange however, is
that it is only displayed at the second invocation of C-x C-e. If you
for example move point left and right and evaluate again, you first
get 2, then the above.

> PS. I notice that the output is 2 and not 2.5, I guess the output gets
> truncated to an integer (the decimal part is discarded).

Yes. Try with (average 2.0 3) and you will get 2.5.

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

* Re: What happens when I evaluate the call the second time?
  2007-07-03  9:45 ` Mathias Dahl
@ 2007-07-03 10:00   ` Andreas Schwab
  2007-07-03 14:32     ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2007-07-03 10:00 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: Eric Lilja, emacs-devel

"Mathias Dahl" <mathias.dahl@gmail.com> writes:

>> First C-x C-e after the function, then twice after calling it. The
>> output is:
>> average
>> 2
>> 2 (#o2, #x2, ?\C-b)
>>
>> Now what's the (#o2, #x2, ?\C-b) stuff?
>
> Different ways to express 2 I think. What I find strange however, is
> that it is only displayed at the second invocation of C-x C-e. 

It's a feature, see eval-expression-print-format.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: What happens when I evaluate the call the second time?
  2007-07-03 10:00   ` Andreas Schwab
@ 2007-07-03 14:32     ` Lennart Borgman (gmail)
  2007-07-03 16:03       ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman (gmail) @ 2007-07-03 14:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eric Lilja, emacs-devel, Mathias Dahl

Andreas Schwab wrote:
> "Mathias Dahl" <mathias.dahl@gmail.com> writes:
> 
>>> First C-x C-e after the function, then twice after calling it. The
>>> output is:
>>> average
>>> 2
>>> 2 (#o2, #x2, ?\C-b)
>>>
>>> Now what's the (#o2, #x2, ?\C-b) stuff?
>> Different ways to express 2 I think. What I find strange however, is
>> that it is only displayed at the second invocation of C-x C-e. 
> 
> It's a feature, see eval-expression-print-format.

I think the thing Erik is asking about is why the output is different in 
the second evaluation.

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

* Re: What happens when I evaluate the call the second time?
  2007-07-03 14:32     ` Lennart Borgman (gmail)
@ 2007-07-03 16:03       ` Andreas Schwab
  2007-07-03 16:07         ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2007-07-03 16:03 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: Eric Lilja, emacs-devel, Mathias Dahl

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:

> Andreas Schwab wrote:
>> "Mathias Dahl" <mathias.dahl@gmail.com> writes:
>>
>>>> First C-x C-e after the function, then twice after calling it. The
>>>> output is:
>>>> average
>>>> 2
>>>> 2 (#o2, #x2, ?\C-b)
>>>>
>>>> Now what's the (#o2, #x2, ?\C-b) stuff?
>>> Different ways to express 2 I think. What I find strange however, is
>>> that it is only displayed at the second invocation of C-x C-e. 
>>
>> It's a feature, see eval-expression-print-format.
>
> I think the thing Erik is asking about is why the output is different in
> the second evaluation.

That's the feature.  You get the verbose output with the second try.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: What happens when I evaluate the call the second time?
  2007-07-03 16:03       ` Andreas Schwab
@ 2007-07-03 16:07         ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 6+ messages in thread
From: Lennart Borgman (gmail) @ 2007-07-03 16:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eric Lilja, emacs-devel, Mathias Dahl

Andreas Schwab wrote:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
> 
>> Andreas Schwab wrote:
>>> "Mathias Dahl" <mathias.dahl@gmail.com> writes:
>>>
>>>>> First C-x C-e after the function, then twice after calling it. The
>>>>> output is:
>>>>> average
>>>>> 2
>>>>> 2 (#o2, #x2, ?\C-b)
>>>>>
>>>>> Now what's the (#o2, #x2, ?\C-b) stuff?
>>>> Different ways to express 2 I think. What I find strange however, is
>>>> that it is only displayed at the second invocation of C-x C-e. 
>>> It's a feature, see eval-expression-print-format.
>> I think the thing Erik is asking about is why the output is different in
>> the second evaluation.
> 
> That's the feature.  You get the verbose output with the second try.

Thanks, I see. But eval-expression-print-format does not tell about this 
AFAICS, or?

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

end of thread, other threads:[~2007-07-03 16:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-02 22:20 What happens when I evaluate the call the second time? Eric Lilja
2007-07-03  9:45 ` Mathias Dahl
2007-07-03 10:00   ` Andreas Schwab
2007-07-03 14:32     ` Lennart Borgman (gmail)
2007-07-03 16:03       ` Andreas Schwab
2007-07-03 16:07         ` Lennart Borgman (gmail)

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