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: a07f3367d7,ab1d177a5a26577d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 18 Feb 2011 01:13:04 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.14) Gecko/20110123 Thunderbird/3.1.8 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> <4d5d8a0b$0$6768$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d5db990$0$6972$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 18 Feb 2011 01:13:04 CET NNTP-Posting-Host: 8fdea0c2.newsspool4.arcor-online.net X-Trace: DXC=IRn3>T]mIE>85[]]\]T0814IUKejV8IdnKl\\Qf]; X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:17389 Date: 2011-02-18T01:13:04+01:00 List-Id: On 2/17/11 10:08 PM, Yannick DuchĂȘne (Hibou57) wrote: > Le Thu, 17 Feb 2011 21:50:20 +0100, Georg Bauhaus a Ă©crit: >> Oddly enough, it is good practice to *not* play the inference >> game when creating "models" in ML languages: when ML programmers >> describe a structure or type, they use type names explicitly. >> Every function is written in terms of its (typed) profile, >> not just the names. > Not sure I've understood. Could you give a short example ? For example in OCaml's standard library everything has an interface. val copy : string -> string (** Return a copy of the given string. *) To me, this seems to represent the modeling part; the implementation would be the real thing, not the model. More importantly, programmers wishing to just use the string (model) would look at the interface. No type inference so far. ML is similar. It has signatures for its structs. Haskell definitions are frequently prefixed with function type, every major (model) definition states its type explicitly. Here is a quote from the prelude. class (Eq a, Show a) => Num a where (+), (-), (*) :: a -> a -> a Thus if you want to know what (*) stands for in Haskell, you will find it here. "Generic" type /a/ is explicitly a Num and an instance of Eq and Show. Specifying types explicitly also helps early error detection: let f1 = function x -> function y -> x +. y ;; let f2 = function (x : int) -> function (y : int) -> x +. y ;; let test1 = f1 3 4 ;; let test2 = f2 3 4 ;; Both f2 and test1 trigger a diagnostic message. test1 finds the mistake in the definition of f1, but arguably, that's too late! f2's error is detected immediately when it has been read. So, apparently, type inference is used by programmars when writing small local things, but not to replace explicit type annotations.