[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing dotted pairs with AND and OR



    Date: Thu, 11 Feb 88 12:06:57 CST
    From: Daniel A Haug <aihaug@AUSTIN.LOCKHEED.COM>


    Check this out:

    --> '(and . foo)
    #<error printing object CONS nnnnnn>

    The problem is that AND and OR have a property GPRINT::FORMATTER that
    specifies GPRINT::FORMAT-AND-OR as the format function.  Looking at the
    source for this function reveals a call to LENGTH on the output form,
    for which a dotted pair causes great grief.

    I can hack a fix to this, but I'm not much of a systems person when it
    comes to making system-type fixes.  Can anyone suggest a fix to me?
    Wonder if this is fixed in 7.2?

It is fixed in 7.2.  Try this for a workaround.  I haven't verified that
this code will run in 7.1, but it looks trivial.

;;; -*- Mode: LISP; Package: GPrint; Syntax: Common-Lisp; Lowercase: Yes -*-
;;;
;;; AND and OR: Stack vertically unless only two long and
;;; one or the other is an atom or the second is a GO.
(defun format-and-or (x)
  (cond ((cdr (last x))
	 (format-1block x))
	((and (= (length x) 3)
	      (simple-p (second x))
	      (simple-p (third x)))
	 (format-function x))
	(t
	 (gformat  "(*_<*!>)" x))))