From: Daniel Klein
Subject: format question
Date: 
Message-ID: <foh8k3do2kvs2a746v261tjcl6dl1citrc@4ax.com>
How come

(format nil "~r" 1606938044258990275541962092)

works in REPL but not in the scratch buffer?

I'm pretty new at all this.

Daniel Klein

From: Zach Beane
Subject: Re: format question
Date: 
Message-ID: <m3oddnikc1.fsf@unnamed.xach.com>
Daniel Klein <·······@featherbrain.net> writes:

> How come
>
> (format nil "~r" 1606938044258990275541962092)
>
> works in REPL but not in the scratch buffer?
>
> I'm pretty new at all this.

Works for me in *slime-scratch*:

  (format nil "~r" 1606938044258990275541962092) ; C-j =>
  "one octillion six hundred six septillion nine hundred thirty-eight
  sextillion forty-four quintillion two hundred fifty-eight quadrillion
  nine hundred ninety trillion two hundred seventy-five billion five
  hundred forty-one million nine hundred sixty-two thousand ninety-two"

Are you in the SLIME scratch buffer? 

Zach
From: David Golden
Subject: Re: format question
Date: 
Message-ID: <TxY0j.23323$j7.443433@news.indigo.ie>
Daniel Klein wrote:

> How come
> 
> (format nil "~r" 1606938044258990275541962092)
> 
> works in REPL but not in the scratch buffer?
> 
> I'm pretty new at all this.
>

What REPL and what scratch buffer? I assume you're in emacs? Sounds
like you're using the emacs lisp scratch bufffer and a common lisp repl. 

Emacs Lisp is different to, and somewhat old-fashioned compared to,
Common Lisp.  Emacs Lisp is the 
scripting-and-a-lot-of-the-implementation language of emacs.

In GNU Emacs lisp, there are two main reasons that won't work:
(i) Emacs lisp format is different to common lisp format, it takes
more C-printf-like format strings.
(ii) Emacs lisp doesn't have bignums anyway (XEmacs can IIRC).

The buffer name and mode name are normally shown
in the emacs modeline, the ones listed below are typical.

*** SLIME REPL:

buffer : *slime-repl <lispname>* 
mode: REPL

A slime repl is an interface to an emacs-external lisp implementation,
typically commmon lisp, though there is a backend for a scheme
(slime48). 

*** ILISP REPL:

buffer: *inferior-lisp*
mode: Comint

An "inferior lisp" repl is an interface to an emacs-external lisp too,
but less featureful than slime's repl.  Slightly confusingly, in the
usual case, slime also _uses_ an ilisp buffer underneath as an
implementation detail for launching+managing an external lisp process. 
Sometimes beginners get the slime repl and ilisp repl mixed up.

*** IELM (EMACS LISP) REPL:

buffer: *ielm*
mode: IELM

And of course, I should mention M-x ielm  , that gives you
a handy repl a bit like ilisp/comint/slime for emacs lisp itself.


*** EMACS SCRATCH:

buffer: *scratch*
mode: Lisp Interaction

The emacs scratch buffer starts out as "for" emacs lisp (and general
junk). Expressions you enter into it and C-j will be evaluated by emacs
lisp.

*** SLIME SCRATCH:

buffer: *slime-scratch*
modes: Lisp Slime

A "slime scratch" buffer is available in slime, if you do
M-x slime-scratch

That gives you a buffer that works much like emacs' scratch, only
it sends the expressions to the slime-connected external lisp, not
emacs lisp.
From: Paul Donnelly
Subject: Re: format question
Date: 
Message-ID: <pan.2007.11.22.05.06.55.264112@sbcglobal.net>
On Wed, 21 Nov 2007 09:58:02 -0500, Daniel Klein wrote:

> How come
> 
> (format nil "~r" 1606938044258990275541962092)
> 
> works in REPL but not in the scratch buffer?
> 
> I'm pretty new at all this.
> 
> Daniel Klein

Assuming you are in fact typing in the proper *slime-scratch* buffer, are
you pressing the correct key to evaluate it? C-j in that buffer will
evaluate the form the point is after, insert any text it prints into the
buffer, then insert the form's return value. C-x C-e will evaluate it
and append printed text to the *slime-repl xxxx* buffer (where xxxx is the
Lisp you're using).
From: Daniel Klein
Subject: Re: format question
Date: 
Message-ID: <fd2bk3dog66m3u6l0l87es7uj15okq8o3v@4ax.com>
On Wed, 21 Nov 2007 23:06:55 -0600, Paul Donnelly
<·············@sbcglobal.net> wrote:

>On Wed, 21 Nov 2007 09:58:02 -0500, Daniel Klein wrote:
>
>> How come
>> 
>> (format nil "~r" 1606938044258990275541962092)
>> 
>> works in REPL but not in the scratch buffer?
>> 
>> I'm pretty new at all this.
>> 
>> Daniel Klein
>
>Assuming you are in fact typing in the proper *slime-scratch* buffer, are
>you pressing the correct key to evaluate it? C-j in that buffer will
>evaluate the form the point is after, insert any text it prints into the
>buffer, then insert the form's return value. C-x C-e will evaluate it
>and append printed text to the *slime-repl xxxx* buffer (where xxxx is the
>Lisp you're using).

Thanks to all who replied.

I should have mentiioned that I am using Lispbox and the 'format'
example above is straight out of Practical Common Lisp.

I didn't know there were 2 types of 'scratch' buffers, and I
especially didn't know how to start up the 'slime-scratch' one. Now
that I do, everything works as expected :-)

<rhetorical question>
How does someone discover this stuff on their own?
</rhetorical question>

Daniel Klein
From: Alex Mizrahi
Subject: Re: format question
Date: 
Message-ID: <4746f1b5$0$90267$14726298@news.sunsite.dk>
 DK> <rhetorical question>
 DK> How does someone discover this stuff on their own?
 DK> </rhetorical question>

doing everything themselves.
for example, you first get Emacs, check emacs lisp there.
then you get CLISP, check REPL.
then you get SLIME, and configure it, so you can work in Emacs with CLISP.

this can take few days to figure out, but you should have better knowledge 
of different components afterwards