Any Common Lisp function returns 3 values?

Is there any Common Lisp function (built-in) that returns more than two values? I know many who return 2, but I cannot think of what returns 3.

(I saw here a comment about returning more than two values, and tried to think about the case when CL did this, but cannot.)

+3
source share
4 answers

There is a get-setf extension function. It returns 5 values.

+4
source

Yes, such functions exist. The following is a complete list of functions in the COMMON-LISP package that return exactly three values, as indicated in the SBCL source code:

COMPILE                                 required: 3, optional: 0, rest?: NIL
INTEGER-DECODE-FLOAT                    required: 3, optional: 0, rest?: NIL
COMPILE-FILE                            required: 3, optional: 0, rest?: NIL
GET-PROPERTIES                          required: 3, optional: 0, rest?: NIL
FUNCTION-LAMBDA-EXPRESSION              required: 3, optional: 0, rest?: NIL
DECODE-FLOAT                            required: 3, optional: 0, rest?: NIL
RENAME-FILE                             required: 3, optional: 0, rest?: NIL

, :

DECODE-UNIVERSAL-TIME                   required: 9, optional: 0, rest?: NIL
GET-DECODED-TIME                        required: 9, optional: 0, rest?: NIL

, :

NO-APPLICABLE-METHOD                    required: 0, optional: 0, rest?: T
NO-NEXT-METHOD                          required: 0, optional: 0, rest?: T
VALUES                                  required: 0, optional: 0, rest?: T

(I've omitted some functions from this list where SBCL does not declare
a values type explicitly.  get-setf-expansion is one of them.)

: required - , optional , SBCL , rest? , . ( macroexpand macroexpand-1 & optional, , .)

, , :

(do-external-symbols (sym :common-lisp)                                         
  (when (fboundp sym)                                                           
    (multiple-value-bind (required optional rest)                               
        (let ((fun-type (sb-int:info :function :type sym)))                     
          (etypecase fun-type                                                   
            (sb-kernel:fun-type                                                 
             (let ((returns                                                     
                    (sb-kernel:fun-type-returns fun-type)))                     
               (etypecase returns                                               
                 (sb-kernel:values-type                                         
                  (values (length (sb-kernel:values-type-required returns))     
                          (length (sb-kernel:values-type-optional returns))     
                          (sb-kernel:values-type-rest returns)))                
                 (sb-kernel:named-type                                          
                  (if (sb-kernel:named-type-name returns)                       
                      (values 1 0 t)                                          
                      (values 0 0 nil))))))                                     
            (t                                                                  
             (values 0 0 t))))                                                  
      (format t                                                                 
              "~A~40Trequired: ~D, optional: ~D, rest?: ~A~%"                   
              sym                                                               
              required optional rest))))
+27

decode-universal-time returns nine values.

+7
source

VALUES and VALUES-LIST , among others.

+2
source

Source: https://habr.com/ru/post/1702499/


All Articles