Path: utzoo!mnetor!uunet!mcvax!ukc!its63b!aiva!jeff From: jeff@aiva.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: Common Lisp lacks portability Message-ID: <216@aiva.ed.ac.uk> Date: 19 Dec 87 22:01:15 GMT References: <1421@orstcs.CS.ORST.EDU> <233@spt.entity.com> <2126@ulowell.cs.ulowell.edu> Reply-To: jeff@uk.ac.ed.aiva (Jeff Dalton) Organization: Dept. of AI, Univ. of Edinburgh, UK Lines: 46 Keywords: Common Lisp In article <2126@ulowell.cs.ulowell.edu> ross@swan.cs.ulowell.edu (Ross Miller) writes: >An implementation is free to ignore type checking and not return any errors, >but it must except the code that declares type checking. That is not a >quote, but it is the jist. Here is a case where a program could be perfectly >debugged and still fail. Here is a way to think about type checking in Common Lisp: * Assume there is no type checking unless you explicitly code it by writing calls to CHECK-TYPE or your own tests and error calls. This assumption may well be correct for compiled code in some implementations. Note that CHECK-TYPE is a way to signal an error, not a declaration. An implementation is not free to ignore it. * Write your code with enough explicit checks so that users cannot confuse it with incorrect data. Use any additional internal checks that you feel are needed. Here I am assuming that only certain routines will be part of the external interface. You can enforce this by using packages (yes, I know one *can* still call internal procedures) or by using FLET and LABELS to keep internal routines local. * In cases where you are sure the types are correct, and where the speed of the compiled code is important, add declarations to inform the compiler of the types involved. It may then generate type-specific but more efficient code. Since you have actually checked the types somewhere, and have done a bit of type inference, you can be confient that the declarations are safe. Code of this sort will be portable. >On another subject have I missed the argument on why arrays are not >always passed by value? Are they sometimes not passed by value? Note that in Lisp objects, such as arrays, aren't copied when passed as parameters: in another language, they would be pointers. Jeff Dalton, JANET: J.Dalton@uk.ac.ed AI Applications Institute, ARPA: J.Dalton%uk.ac.ed@nss.cs.ucl.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton