From ... From: Erik Naggum Subject: Re: Newbie questions Date: 1999/05/04 Message-ID: <3134844303370291@naggum.no>#1/1 X-Deja-AN: 474080115 References: <87btg5pb1y.fsf@2xtreme.net> <372dc20d.11142383@news.select.net> <37326ec5.11965212@news.select.net> <87g15ee8ss.fsf@foobar.orion.no> <372e265f.2137369@news.select.net> <87d80hdy1t.fsf@foobar.orion.no> <372fb91b.39706364@news.select.net> <87aevldw62.fsf@foobar.orion.no> <7gnhjt$p9q$1@nnrp1.dejanews.com> mail-copies-to: never Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.ai,comp.lang.lisp * Bagheera, the jungle scout | I think what josh is getting at is that in C++, it prevents you from | stuffing an 8byte value into a two byte parameter. If you don't have | type checking for this sort of thing, you can easily overflow your | calling stack, which is a bad no-no. Basically it is a matter of the | program protecting itself from the programmer. this is not what static types are about. having static types _allows_ a compiler to skimp on (some) run-time type checking in the belief that all or most of the necessary type checking can be performed compile-time. this is, of course, as ridiculous a desire as wanting the compiler to prove the program free of any other bug, and has confused people to no end about what types are. the important property of static types is not what would happen if you took it away, but what happens when you introduce it: you can take away some fences that you presume the compiler took care of, but the only actual consequence is that you leave open the whole area of precisely the kind of bugs you mistakenly associate with languages and compilers with dynamic types. even in the machine language, there are types and associated operations on them. some of the types may look very much the same when stored as bits in machine memory, but that is really an artifact of a context-dropping human viewer -- the archetypical example is the C notion of a pointer and its interchangeability with integers of some size. the stored pointer doesn't become an integer any more than a parked car becomes a source of money when broken into by a thief -- in both cases, it's how you use it that matters, and we have laws and regulations that say that parked cars are just that and not sources of money. if you willfully transgress these laws, you can turn a parked car into a source of money, but most people know they're doing something wrong when they do this, and even the lowliest thief who knows this is morally superior to the C programmer who abuses the bits of a pointer as an integer and takes it for granted. any form of representation is subject to interpretation by a conscious mind that imputes meaning to the inherently meaningless. if, however, you partition the otherwise confusing representation space into various categories and make certain that you know which category something is of even at run-time, you don't get into the kinds of silly troubles that C/C++ fans think static typing got them out of: they never happen in the first place. or, to be more precise, any powerful system will allow you to break the rules, but it has to be on purpose, not by silly mistake, which is, unfortunately, what C/C++ give you absent static type checks. so, "if you don't have type checking for this sort of thing", you move that type checking into the run-time, instead, and you _can't_ overflow your calling stack. I'd argue that _dynamic_ typing is how a program protects itself from the programmer, and static typing that makes a whole lot of errors and problems _arise_. | I'm sure there are lots of ways to shoot yourself in the foot with Lisp. how did you acquire your certainty about this who know nothing about what to do if you don't do static typing? (hint: if you want to destroy the world through Lisp, you have to work hard at it. if you want to destroy the world through C/C++, simply derefence a stray pointer or _forget_ to check for NULL, which is _manual_ run-time type checking.) | C++ is a concerted effort to reduce that possibility of self-destruction. it must be Slobodan Milosovic's favorite programming language, then. | True, Lisp gives you the option of run-time program correction... but | sometimes requirements don't allow that comfort. you know, I'm a little irritated by the ignorant newbies who come here and on other lists and aske all sorts of inane questions, but it beats having to deal with ignorants who think they now enough to make blanket statements. #:Erik