Posts by carlozancanaro@aus.social
 (DIR) Post #AWTxiV0F02dg8HcaMy by carlozancanaro@aus.social
       2023-06-08T13:05:42Z
       
       0 likes, 0 repeats
       
       @galdor Common Lisp's types are very frustrating. They're too low-level to helpfully model application-level things. I frequently want to do some "type-directed" stuff with classes and/or macros, but the type system makes it hard to do so using standard types.For lists, I hack something together like this:(defun make-sequence-predicate (item-type)  (let ((name (intern (format nil "SEQUENCE-OF-~a" item-type))))    (unless (fboundp name)      (setf (fdefinition name)            (lambda (object)              (every (lambda (item)                       (typep item item-type))                     object))))    name))(deftype list-of (item)  (if (eq item '*)      'list      `(and list (satisfies ,(make-sequence-predicate item)))))