[cl-typesetting-devel] CLISP support

Klaus Weidner kw at w-m-p.com
Sun Apr 25 23:00:25 UTC 2004


On Sun, Apr 25, 2004 at 11:09:04PM +0200, Marc Battyani wrote:
> Hum, I don't buy this argument as nobody uses cl-typesetting with clisp yet.
> I remind you that you made the port yesterday ;-) So it's not a problem to
> say that cl-typesetting works with clisp version > 42.

Yes it is a problem, and I don't see why we should make life
unnecessarily difficult for people if the problem is so easy to work
around. A reason why I worked on the port is because I *need* it to work
with existing CLISP installations.

Keep in mind that this is not an extremely major brokenness in CLISP that
would make people upgrade in any case. It's a case of different
interpretation of a badly-defined part of the standard, and I would not
be surprised if yet other Lisp implementations would again have different
behavior. And the workaround is painless.

FYI, I'm not all that opposed to loop, and I think it's clearer than
DO in many cases. But the unclear loop termination rules are not
something I'd want to depend on. Keep in mind that if even the compiler
implementors have a hard time figuring out what the behavior is supposed
to be, the risk that a blurry-eyed programmer working with the code
will get the wrong mental model is very high.

> ?? The #+clisp is only related to the on-list and max-height problems.
> For the on-list one I will ask the clisp developpers it's not ill-defined as
> you say IMO, and for the max-height one the patch works for clisp but is not
> guaranted to work with every implantation as it is unspecified according to
> the standard. (Though I don't see why there would be anything else than nil
> or 0)

I fixed the max-height problem for all platforms in the attached patch,
so I think this point is moot.

For the on-list bug, I refactored v-split. See below for the full code,
since it's harder to see what's going on in the patch.  I think this is a
cleaner solution than the old code.

One more thing, please remove the #+(or ...) in cl-typesetting.asd, it
should not be needed anymore.

-Klaus

(defmethod v-split ((table multi-page-table) dx dy &optional v-align)
  "Factor out rows that fit and return as a first value."
  ;; Treat unsplittable rows as a single unit - for this purpose,
  ;; group the rows-left list into the following form:
  ;;
  ;;     ( (group1-height row1 row2 ...)
  ;;       (group2-height row7)
  ;;       (group3-height row8 row9 ...) )
  ;;
  (with-slots (header footer border padding cell-padding) table
    (loop with boxes = ()
	  and current-height = (+ border
				  padding
				  (reduce #'+ header :key #'dy)
				  (reduce #'+ footer :key #'dy))
	  and row-groups = (loop with height = 0
				 and  rows = ()
	
				 for row in (rows-left table)
				 do
				 (incf height (+ (height row)
						 (* 2 cell-padding)
						 border))
				 (push row rows)

				 when (splittable-p row)
				   collect (cons height (nreverse rows))
				   and do (setf height 0 rows nil))
	  and rows-remaining = (rows-left table)
	  
          for (group-height . rows) in row-groups
	  while (<= (+ current-height group-height) dy)

	  do (dolist (r rows)
	       (push r boxes)
	       (pop rows-remaining))
	     (incf current-height group-height)
	  
	  finally
	  (when boxes
	    (setq boxes (append header (nreverse boxes) footer))
	    (setf (rows-left table) rows-remaining)
	    (decf (slot-value table 'dy) current-height)
            (let ((first (first boxes))
                  (last (first (last boxes))))
              (setf (slot-value first 'position) :first
                    (slot-value last 'position) (if (eq first last)
		                                    :single :last)))
	    (return (values boxes
			    rows-remaining
			    (- dy current-height))))
	  (return (values nil rows-remaining dy)))))




More information about the cl-typesetting-devel mailing list