From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab1d177a5a26577d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 17 Feb 2011 11:27:26 -0600 Newsgroups: comp.lang.ada Date: Thu, 17 Feb 2011 12:27:11 -0500 From: "Peter C. Chapin" Subject: Re: What's wrong with C++? In-Reply-To: <17coueqbf1p27.1g0wj3010saxe$.dlg@40tude.net> Message-ID: References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> <17coueqbf1p27.1g0wj3010saxe$.dlg@40tude.net> User-Agent: Alpine 2.00 (WNT 1167 2008-08-23) X-X-Sender: pcc09070@vtc.vsc.edu@webmail.vtc.edu MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-A1kwDn/iQSz5yMLxTH3Kw7w5cRyMpQ0TWrZg1esTnUJHGsrVsWQ2P57uBgwEhqr+63fGg5yO5USLOj0!0msH8DKToyEwmoX9RH994IEdRyW8HtDoB9NjuZXQqgRrx9NaaJ69pPNdfH5nawWanYVnClVi X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4023 Xref: g2news2.google.com comp.lang.ada:18312 Date: 2011-02-17T12:27:11-05:00 List-Id: On Thu, 17 Feb 2011, Dmitry A. Kazakov wrote: >> Could you elaborate a little on why you think type inference is bad? In >> the functional languages that support it, type inference is completely >> type safe (for example: Haskell, OCaml, Scala). Perhaps you mean >> something different. > > The first notice is that inferred types cannot be safe per definition. > There is no additional information involved. What is inferred, already is. > To me safety is when some a-priori information unknown to the compiler (and > to the language designers) is used to detect sematic problems. I understand this point. I believe you are saying that types are part of the program's design and thus asserting them in the program explicitly (and having the compiler check the resulting code) brings information from the design into the compiler's view. > The second note is that if types are not the things from the problem space > (of which the compiler knows little or nothing), then what kind of stuff > is there in their place? I presume that nothing. You can still define the types you need. Inference just means that you typically don't have to bother with explicit declarations: create the objects you need (of the types you need) and let the compiler work out the details. > Now the main objection is computability and decidability. Only "simple" > things can be inferred. The compiler cannot solve problems beyond > Turing-completeness... It sounds like you are taking "type inference" to mean that the compiler figures out pre-conditions, post-conditions, etc. I'm just talking about the compiler recovering type information based on how entities are used. For example, in OCaml: let rec sum_items alist = match alist with [] -> 0 | head::tail -> head + (sum_items tail) The compiler infers that sum_items is a function taking a list of ints and returning an int. It does this by looking at what the code does: mylist is being matched against a list pattern. The head element of the list is an int because of its use with +. The branches of the match both agree in their type (int) which is the type returned by the function which is consistent with its use in the summation operation. The algorithms for doing this are well understood and they are decidable. On the other hand there are undecidable type systems, it's true. I've heard it said that Scala's type system is undecidable. However, nobody much cares because the programs that force the type checker into nontermination are so weird that no normal developer would ever write them (so it is claimed). Peter