Path: utzoo!attcan!uunet!dlogics!dsa From: dsa@dlogics.COM (David Angulo) Newsgroups: comp.object Subject: Re: Do we really need types in OOPL's? Summary: Your statements show the REASON that typed-checked languages are better Message-ID: <668@dlogics.COM> Date: 22 Oct 90 15:54:40 GMT References: <1990Oct9.190813.23402@ux1.cso.uiuc.edu> <2444@runxtsa.runx.oz.au> <1990Oct19.220747.5536@Neon.Stanford.EDU> Organization: Datalogics Inc., Chicago Lines: 44 In article <1990Oct19.220747.5536@Neon.Stanford.EDU>, craig@Neon.Stanford.EDU (Craig D. Chambers) writes: | In article <1990Oct19.180646.8649@ux1.cso.uiuc.edu> render@cs.uiuc.edu (Hal Render) writes: | | Consider the perform: primitives in Smalltalk. These are very hard to | type-check without doing analysis of the possible *values* of the | run-time selector. No static type system I know of can statically | type check a perform: primitive in any but the most trivial cases. | The user interface in Smalltalk uses perform: all the time to execute | arbitrary user actions when a menu entry is selected. Become: is | another hard-to-type-check primitive in Smalltalk. The perform: is, in fact, one case where checking is NEEDED. I have been using c++ for nearly two years now and have just (the last two months) started using Smalltalk. I had a bug using the perform: message that took me two days to find because the compiler wasn't smart enough to catch it for me. (The cause: I had capitalized the symbol that was being used in the perform: message. The result: the compiler did not complain, the run time program did not complain, but the application did not work - highly unsatisfactory). | | Another case in Smalltalk is the implementation of growable arrays (I | think; some collection in Smalltalk has this problem). The | representation of a growable array is a vector of indexable fields, a | lower bound, and an upper bound (or maybe a length, I don't remember). | The elements of the growable array are in the fields indexed between | the lower bound and the upper bound; the contents of the extra padding | fields are nil. This poses problems for a static type checker, since | the best static type systems that I've seen will treat the type of the | indexable fields as "T | Nil" (where "T" is the parameterized type of | the elements of the growable array). So fetches out of the indexed | fields return objects that the type checker thinks are of type "T | | Nil", while the programmer knows that they really should be just "T". | Well, I have made growable arrays in c++ for a long time with satisfactory results so your objections must be implementation dependant and not due to the methodology of static type checking in itself. -- David S. Angulo (312) 266-3134 Datalogics Internet: dsa@dlogics.com 441 W. Huron UUCP: ..!uunet!dlogics!dsa Chicago, Il. 60610 FAX: (312) 266-4473