[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Predicates for types.
- To: "BACH::GREEK" <email@example.com>, NGALL@G.BBN.COM, Fischer.pa@Xerox.COM, Scott E. Fahlman <Fahlman@C.CS.CMU.EDU>, Skef Wholey <Wholey@C.CS.CMU.EDU>, David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>, common-lisp <common-lisp@SU-AI.ARPA>
- Subject: Predicates for types.
- From: David C. Plummer <DCP@SCRC-QUABBIN.ARPA>
- Date: Mon, 31 Mar 86 10:05 EST
- In-reply-to: The message of 28 Mar 86 12:32-EST from "BACH::GREEK" <firstname.lastname@example.org>, <[G.BBN.COM]28-Mar-86 11:20:13.NGALL>, <860328-143519-3626@Xerox>, <FAHLMAN.12194428457.BABYL@C.CS.CMU.EDU>, <[G.BBN.COM]29-Mar-86 15:54:53.NGALL>, <WHOLEY.12194653947.BABYL@C.CS.CMU.EDU>, <FAHLMAN.12194693455.BABYL@C.CS.CMU.EDU>, <860329215031.1.MOON@EUPHRATES.SCRC.Symbolics.COM>
One reason to have specific predicates is efficiency. This is not just
an implementation detail hidden by the compiler, such as
(typep foo 'number)
I admit the user should probably use those constructs instead of the -P
predicates and instead let the compiler do the fun. Other constructs,
however, do not lend themselves to this abstraction. Would you rather
(count-if #'integerp sequence)
(count-if #'(lambda (object) (typep object 'integer)) sequence)
?? In addition to which would you rather type, which would you rather
read in somebody else's code?