From: Jimka
Subject: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <1156597806.073143.187300@m73g2000cwd.googlegroups.com>
I have noticed that if i set the *print-base* to 32, sbcl will print
NIL as |NIL|
in the repl, but not inside a format ~A directive.   Does anyone know
if this is
the correct behavior?

From: ········@gmail.com
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <1156600276.635747.233440@m79g2000cwm.googlegroups.com>
Jimka wrote:
> I have noticed that if i set the *print-base* to 32, sbcl will print
> NIL as |NIL|
> in the repl, but not inside a format ~A directive.   Does anyone know
> if this is
> the correct behavior?

Maybe this will clarify:

* (setf *print-base* 32)

10

* 23

N

Eirik.
From: ········@gmail.com
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <1156600483.607016.146800@p79g2000cwp.googlegroups.com>
········@gmail.com wrote:
> Jimka wrote:
> > I have noticed that if i set the *print-base* to 32, sbcl will print
> > NIL as |NIL|
> > in the repl, but not inside a format ~A directive.   Does anyone know
> > if this is
> > the correct behavior?
>
> Maybe this will clarify:
>
> * (setf *print-base* 32)
> 
> 10
> 
> * 23
> 
> N
> 

Or, to elaborate ;) :

* 24149

NIL

Eirik.
From: Jimka
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <1156601080.869328.298220@75g2000cwc.googlegroups.com>
Hi eirik, it does not clarify but in fact just reiterates my question.
How should symbols print in the repl and how should they print
with format ~A when the *print-base* is different from 10?

-jim

········@gmail.com wrote:
> Jimka wrote:
> > I have noticed that if i set the *print-base* to 32, sbcl will print
> > NIL as |NIL|
> > in the repl, but not inside a format ~A directive.   Does anyone know
> > if this is
> > the correct behavior?
>
> Maybe this will clarify:
> 
> * (setf *print-base* 32)
> 
> 10
> 
> * 23
> 
> N
> 
> Eirik.
From: ········@gmail.com
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <1156602419.003516.98850@75g2000cwc.googlegroups.com>
Jimka wrote:
> Hi eirik, it does not clarify but in fact just reiterates my question.
> How should symbols print in the repl and how should they print
> with format ~A when the *print-base* is different from 10?
>

Yeah, I was a bit quick on the trigger there.

(format t "~A~A" 'nil 24149) prints "NILNIL" in SBCL. Allegro CL also
prints without pipes, but uses lower-case for the numerical value, so
it becomes "NILnil". At least in Allegro CL you can tell the
difference.

Both are correct behaviour since ~A is "aestetic" printing, objects are

printed without any escape characters. If you use ~S (standard) you
will get pipes around NIL.

(format t "~A ~S" 'nil 'nil)

NIL |NIL|

Eirik.
From: Pascal Bourguignon
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <87hczzwen9.fsf@thalassa.informatimago.com>
"Jimka" <·····@rdrop.com> writes:
> ········@gmail.com wrote:
>> Jimka wrote:
>> > I have noticed that if i set the *print-base* to 32, sbcl will print
>> > NIL as |NIL|
>> > in the repl, but not inside a format ~A directive.   Does anyone know
>> > if this is
>> > the correct behavior?
>>
>> Maybe this will clarify:
>> 
>> * (setf *print-base* 32)
>> 
>> 10
>> 
>> * 23
>> 
>> N
>> 
>> Eirik.
>
> Hi eirik, it does not clarify but in fact just reiterates my question.
> How should symbols print in the repl and how should they print
> with format ~A when the *print-base* is different from 10?

(loop for *print-readably* in '(nil t)
       do (format t "*print-readably* = ~S~%" *print-readably*)
          (let ((*print-base* 36))
             (format t "~{~A ~:* ~S ~:* ~W~%~}" '(nil #36rNIL))))
*print-readably* = NIL
NIL  |NIL|  |NIL|
NIL  NIL  NIL
*print-readably* = |COMMON-LISP|::|T|
NIL  |COMMON-LISP|::|NIL|  |COMMON-LISP|::|NIL|
NIL  30477.  30477.

CLHS ~A says that symbols should print without escape.


-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
----------> http://www.netmeister.org/news/learn2quote.html <-----------
---> http://homepage.ntlworld.com/g.mccaughan/g/remarks/uquote.html <---

__Pascal Bourguignon__                     http://www.informatimago.com/
From: Tim Bradshaw
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <ecqegm$sfc$1$830fa7b3@news.demon.co.uk>
On 2006-08-26 14:10:06 +0100, "Jimka" <·····@rdrop.com> said:

> I have noticed that if i set the *print-base* to 32, sbcl will print
> NIL as |NIL|
> in the repl, but not inside a format ~A directive.   Does anyone know
> if this is
> the correct behavior?

Yes, it is correct.  ~A is defined to do what PRINC does, in particular 
it binds *PRINT-ESCAPE* and *PRINT-READABLY* to NIL, so you get just 
the name.  I am not sure the top-level loop is defined tightly enough 
to say, but I'm sure it's fine for an implementation to print results 
with at least *PRINT-ESCAPE* bound to T (in other words to use, say, 
PRINT, not WRITE etc).  In fact that's what I'd hope they'd do.

It's perhaps easier to see what is going on if you consider a symbol 
like what you get by (intern "3" *package*)

--tim
From: Nicola Mingotti
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <44f0d910$0$75040$14726298@news.sunsite.dk>
Jimka wrote:
> I have noticed that if i set the *print-base* to 32, sbcl will print
> NIL as |NIL|
> in the repl, but not inside a format ~A directive.   Does anyone know
> if this is
> the correct behavior?
> 

It's a way for Lisp to make it clear that it means that "NIL"
it returned was a symbol, since now it could also be a number.

try this :

(setf *print-base* 32)
(setf *read-base* 32)
(+ 1 nil)

... now try yourself to return in base 10 than look below

...
...
...

(|SETF| |*READ-BASE*| a)
(setf *print-base* 10)

funny ah ?

bye :)
From: Fabien LE LEZ
Subject: Re: how should symbols be printed when *print-base* is different than 10?
Date: 
Message-ID: <c6q1f217mn7ko4on0n5ahaijc1oi6l6avo@4ax.com>
On Sun, 27 Aug 2006 01:28:16 +0200, Nicola Mingotti <···@bar.baz>:

>funny ah ?

Yup. Now I know a good reason to stay in base 10.