Path: utzoo!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!agate!bionet!ig!arizona!gudeman From: gudeman@arizona.edu (David Gudeman) Newsgroups: comp.lang.misc Subject: Re: Polymorphism (Re: What is B&D?) Message-ID: <8707@megaron.arizona.edu> Date: 13 Jan 89 19:28:38 GMT Organization: U of Arizona CS Dept, Tucson Lines: 30 In article <1228@etive.ed.ac.uk> nick@lfcs.ed.ac.uk (Nick Rothwell) writes: >In article <5818@medusa.cs.purdue.edu> rjh@cs.purdue.edu (Bob Hathaway) writes: >>... Dynamic >>typechecking, which I often refer to as arbitrary polymorphism, is a more >>powerful form and usually cannot be accomplished at compile time. > ^^^^^^^ > >Well, cannot at all, I'd say, by definition of compile-time and dynamic. There are programs called "type-inference" systems that can infer the types of most or all variables in a language that has untyped variables. I suppose there is a distinction between a dynamically typed language and a language that simply doesn't require type declarations. I believe ML is of the latter class (I hope I'm not confusing ML with some other language here). It doesn't require type declarations, but expressions are defined in such a way that the types of all expressions can be inferred at compile time. Dynamically typed languages such Lisp or Icon allow types to be decided at run time. For example, let read_number be a procedure that reads a number from a file: if read_number() < 0 then return 0 else return ["a", "list", "of", "strings"] It is obviously impossible to exactly infer all types in such a language, but it is possible to make approximations. And in most programs, most variables are used in a type-consistent manner, so it is generally possible to infer the types of 80% or more of all variable uses.