Subject: *print-readably* and *print-circle*

From: Sam Steingold <[email-masked]>
Date: 02 Feb 1998 15:09:17 -0500

(let ((*print-readably* t) (*print-circle* t)) (princ zz))
produced
"#S(anls :date #S(date :ye 1993. :mo 2. :da 8.) :slrt #1=0.0d0 :wedg #1#
:sslp #1# :asra 0.4547124023710203d0 :days 2.875d0)"

(read-from-string <the above string>)
==>
*** - the: wedg evaluated to the values (#<read-label 1>), not of type (double-float 0.0 *)
1. Break> 

Comments?

-- 
Sam Steingold

---

From: Bruno Haible <[email-masked]>
Date: Tue, 3 Feb 1998 11:51:25 +0100 (MET)

> *** - the: wedg evaluated to the values (#<read-label 1>), not of type (double-float 0.0 *)

Obviously clisp does not do the right thing, and you have to comment out
the slot's :type declaration to make it work.

It is interesting to note that probably no Common Lisp implementation
can do the right thing:

  > (setq *print-circle* t)
  T
  > (defstruct foo (x nil :type (or null foo)))
  FOO
  > (setq a (make-foo))
  #S(FOO :X NIL)
  > (setf (foo-x a) a)
  #1=#S(FOO :X #1#)
  > (read-from-string "#1=#S(FOO :X #1#)")
  *** - THE: X evaluated to the values (#<READ-LABEL 1>), not of type (OR NULL FOO)

In order to digest the string "#1=#S(FOO :X #1#)", the Lisp implementation
would have to have the object already created so that it can be passed as
argument to the `MAKE-FOO' constructor. CLHS section 2.4.8.16 is silent
about this issue.

                            Bruno

---

From: Sam Steingold <[email-masked]>
Date: 03 Feb 1998 08:50:54 -0500

>>>> In a very interesting message <[email-masked]>
>>>> Sent on Tue, 3 Feb 1998 02:52:59 -0800 (PST)
>>>> Honorable Bruno Haible <[email-masked]> writes
>>>> on the subject of "Re: *print-readably* and *print-circle*":
not an option.

 >> argument to the `MAKE-FOO' constructor. CLHS section 2.4.8.16 is silent

So, I have to set *print-circle* to nil to get readable output, right?
Is there a way to turn off type cheching at run-time? It would be cool
if I could write
	(let ((*type-checking* nil)) (read-from-string whatever))
and it worked.

It would be nice if this made its way to c.l.l (and, eventually, to ANSI
CL)-- but I am already the far above my reasonable quota of postings
there. :-)

-- 
Sam Steingold

---

From: Bruno Haible <[email-masked]>
Date: Tue, 3 Feb 1998 15:34:57 +0100 (MET)

Hi,

>>> It is interesting to note that probably no Common Lisp implementation

Actually, CMUCL, MCL, Genera and compiled CLISP do the right thing (no error),
but they don't check the :type assertions.

Sam Steingold <[email-masked]> writes:
> Is there a way to turn off type cheching at run-time?

Just compile the constructor function `make-foo'. Or wrap the `defstruct'
form into
          (locally #+clisp (declare (compile))
            (defstruct .....)
          )

> CL)

Now I think that it's a bug in clisp, and that a rewrite of `defstruct'
will suffice to make clisp behave correctly even in the presence of
type-checking.

                     Bruno