(defun sum (lst)
(let ((acc 0))
(dolist (x lst)
(setq acc (+ x acc)))
acc))
(sum '("a" "b" "c"))
gives me a runtime error. Does sbcl support parametric polymorphism? (defun sum (lst)
(let ((acc 0))
(dolist (x lst)
(setq acc (+ x acc)))
acc))
(sum '("a" "b" "c"))
gives me a runtime error. Does sbcl support parametric polymorphism?Common Lisp has a (CONS α β) type for cons cells with member types α and β, but its LIST type is defined as (OR (CONS T T) NULL), basically more of a binary tree type, where T is the Common Lisp "any" union of all types.
A useable (LIST α) type would be something like μβ.(OR (CONS α β) NULL), but that's not expressible within standard Common Lisp. I expect it to very hard to infer too, especially with CONS cells being mutable.