Paste number 34536: NIL or not NIL?

Paste number 34536: NIL or not NIL?
Pasted by: _deepfire
When:2 years, 5 months ago
Share:Tweet this! | http://paste.lisp.org/+QNC
Channel:#lisp
Paste contents:
Raw Source | XML | Display As
(defun box-intersect (b0 b1)
  (declare (type box b0 b1))
  (let ((lu (v2max (box-o b0) (box-o b1)))
	(rd (v2min (box-o+d b0) (box-o+d b1))))
    (format t "INTERSECT!~%")
    (when (not (v2minusp-or (v2- rd lu)))
      (let ((r (make-box-pts :lu lu :rd rd)))
	(format t "INTERSECT: ~S~%" r)
	r))))
(declaim (ftype (function (box box) (or nil box)) box-intersect))

(defun vport-render-terrain (vport targetvis)
  (let* ((loc (vport-location vport))
	 (vbox (vport-box vport))
	 (terr (loc-terrain loc))
	 (scale (vport-scale vport))
	 (inters (box-intersect (box-extend-v2 (loc-largest-visdim loc) vbox)
				(make-box :o (v2zero) :d (loc-d loc)))))
    (format t "inters: ~S ~A~%" inters inters)
    (when inters
      (format t "go NONNIL inters: ~S ~A~%" inters inters)
      (do-loc-area (pt inters loc)
	(let ((terrc (aref-v2 terr pt)))
	  (when (and terrc (v2eq (box-o (ent-box terrc)) pt))
	    (visual-blit (v2*i scale (v2- pt (box-o vbox))) (ent-visual terrc) targetvis)))))))


==================== *starndard-output*:
INTERSECT!
inters: NIL NIL
go NONNIL inters: NIL NIL

i.e.: box-intersect returns NIL -- because WHEN in BOX-INTERSECT is not satisfied
i think it also means that this NIL is generated by lisp itself and is guaranteed to be CL:NIL
yet -- WHEN in VPORT-RENDER-TERRAIN thinks that NIL is good and well and is not NIL at all...

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.