ccl icon indicating copy to clipboard operation
ccl copied to clipboard

MAPCAN/MAPCON Edge cases

Open Gleefre opened this issue 2 years ago • 2 comments

MAPCAN/MAPCON functions have two edge cases which are not correctly handled in ccl.

(mapcan #'identity '(1 2 3))  ; should error, returns 3 instead
(mapcon #'car '(1 2 3))       ; same

(setf *print-circle* t)

;; This returns #1=(1 2 . #1#), which is correct
(let ((lst (list 1 2)))
  (flet ((f (x)
           (declare (ignore x))
           lst))
    (apply #'nconc (mapcar #'f '(1 2)))))

;; Should be equivalent to the previous example, but hangs instead.
(let ((lst (list 1 2)))
  (flet ((f (x)
           (declare (ignore x))
           lst))
    (mapcan #'f '(1 2))))

Also please see https://gitlab.common-lisp.net/ansi-test/ansi-test/-/issues/39 .

Tested on ccl v1.12.1 (latest release)

Gleefre avatar May 09 '23 10:05 Gleefre

There's extensive discussion of this at https://gitlab.common-lisp.net/cmucl/cmucl/-/issues/196

xrme avatar Aug 10 '23 19:08 xrme

@gzacharias maybe you'd be interested in looking at this?

CCL and CMUCL share similar source code for mapcan and friends, but there are a few CCL alterations that look like they were authored by you.

xrme avatar Sep 02 '23 01:09 xrme