Subject: Re: Why typing? From: Erik Naggum <email@example.com> Date: 1995/09/25 Newsgroups: comp.software-eng,comp.lang.functional,comp.lang.lisp,msu.cps.misc Message-ID: <19950925T163942Z@naggum.no> [R.S. Nikhil] | Yes, in Lisp you cannot mis-apply a primitive but, for me, safety also | implies never mis-applying user-defined functions. Without this | guarantee, I'd be hard-pressed to concede that Lisp is a type-safe | language. this doesn't make sense. | To take a specific example: if a point in space is represented as a | pair of numbers, then the typical Lisp function that selects the | x-coordinate: | | (define (x-coord pt) (car pt)) | | will happily work with any list I give it, whereas in most statically | typed languages, this mis-application is caught during type-checking. sorry, you're seriously confused. first of all, the above code is Scheme, not Lisp. second, if you use a primitive type to implement a higher-level type and you don't tell the type system, you get exactly the same kind of behavior in statically typed languages. the clue you missed is that you have to tell the type system what you think. in the case of Common Lisp, you use structures or classes, which become new types, which you can properly declare. (it is not Lisp's fault that Scheme lacks structures and classes. credit where credit is due, and blame where blame is due.) | The fact that Lisp has a ``safety-net'' (not present in C and | assembler) in that primitives are never mis-applied, is very useful and | nice, but I still wouldn't call it a type-safe language. that's because you have misunderstood Lisp's safety-net, confuse Scheme with Lisp, and generally talk more than you should. | [Some may claim that my X-COORD reflects bad style: that I should have | used an explicitly tagged data structure for points and checked the tag | in X-COORD. Fine; I can, and do, write such type-safe programs in | Lisp, and so can I, in C and assembler; but the LANGUAGE isn't | type-safe.] yes, it's bad style, but not for the reason you think. the problem is that _you_ aren't type-safe, because you have used the "Lisp" ambiguously. Lisp is a class of languages, not a single language. properties of one of the instances of that class are not necessarily properties of all instances, nor of the class. I strongly suspect you refer to Scheme, and not necessarily a functionally useful implementation of Scheme, either. #<Erik 3021035978> -- tea, earl grey, industrial strength, hot.