comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de>
Subject: Re: What's wrong with C++?
Date: Fri, 18 Feb 2011 01:13:04 +0100
Date: 2011-02-18T01:13:04+01:00	[thread overview]
Message-ID: <4d5db990$0$6972$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <op.vq2foxgxule2fv@douda-yannick>

On 2/17/11 10:08 PM, Yannick Duchêne (Hibou57) wrote:
> Le Thu, 17 Feb 2011 21:50:20 +0100, Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de> 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.



  reply	other threads:[~2011-02-18  0:13 UTC|newest]

Thread overview: 155+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 17:37 What's wrong with C++? KK6GM
2011-02-16 17:58 ` Hyman Rosen
2011-02-16 18:18   ` KK6GM
2011-02-16 20:25     ` Chris Moore
2011-02-20  4:47       ` Chuck
2011-02-20  4:45     ` Chuck
2011-02-16 19:35   ` Robert A Duff
2011-02-16 20:32     ` Hyman Rosen
2011-02-16 23:31     ` Georg Bauhaus
2011-02-16 20:03   ` Fritz Wuehler
2011-02-16 20:09     ` Hyman Rosen
2011-02-17 17:39     ` Paul Colin Gloster
2011-03-01 15:52       ` Martin Krischik
2011-02-16 23:27   ` Peter C. Chapin
2011-02-16 18:32 ` Pascal Obry
2011-02-16 19:09   ` Hyman Rosen
2011-02-16 19:36     ` KK6GM
2011-02-16 20:07       ` Hyman Rosen
2011-02-17 18:48         ` Yannick Duchêne (Hibou57)
2011-02-17 18:53           ` Ludovic Brenta
2011-02-17 19:14             ` Yannick Duchêne (Hibou57)
2011-02-17 19:38             ` Hyman Rosen
2011-02-17 19:55               ` Ludovic Brenta
2011-02-17 20:11                 ` Hyman Rosen
2011-02-17 20:51                   ` Ludovic Brenta
2011-02-17 21:03                     ` Hyman Rosen
2011-02-17 21:32                       ` Ludovic Brenta
2011-02-17 21:45                         ` Hyman Rosen
2011-02-17 21:07                 ` Jeffrey Carter
2011-02-17 20:32               ` Yannick Duchêne (Hibou57)
2011-02-17 20:37                 ` Hyman Rosen
2011-02-17 22:54               ` J-P. Rosen
2011-02-17 23:02                 ` Hyman Rosen
2011-02-17 23:03                 ` Hyman Rosen
2011-02-17 23:17                   ` J-P. Rosen
2011-02-17 23:27                     ` Hyman Rosen
2011-02-18  6:56                       ` J-P. Rosen
2011-02-18 19:58                       ` Edward Fish
2011-02-18 20:04                         ` Hyman Rosen
2011-02-18 20:10                           ` Edward Fish
2011-02-18 20:27                             ` Hyman Rosen
2011-02-18 22:00                               ` Edward Fish
2011-02-17 19:34           ` Hyman Rosen
2011-02-16 20:49   ` Nasser M. Abbasi
2011-02-16 21:12     ` Hyman Rosen
2011-02-16 23:07       ` J-P. Rosen
2011-02-16 23:23         ` Hyman Rosen
2011-02-17 20:51         ` Yannick Duchêne (Hibou57)
2011-02-17 20:57           ` Hyman Rosen
2011-02-16 23:35       ` Peter C. Chapin
2011-02-17  3:35         ` Shark8
2011-02-17 20:54           ` Yannick Duchêne (Hibou57)
2011-02-17 22:19             ` Shark8
2011-02-17 11:04         ` J-P. Rosen
2011-02-17 11:52           ` Georg Bauhaus
2011-02-17 14:30             ` J-P. Rosen
2011-02-17 16:29               ` Hyman Rosen
2011-02-17 17:32                 ` Peter C. Chapin
2011-02-18  6:54                   ` Chuck
2011-02-17 21:04                 ` Yannick Duchêne (Hibou57)
2011-02-18  7:02                   ` Chuck
2011-02-17 22:50                 ` J-P. Rosen
2011-02-17 23:00                   ` Hyman Rosen
2011-02-17 23:08                     ` J-P. Rosen
2011-02-19 15:24                     ` Marco
2011-02-19 16:39                       ` Frank J. Lhota
2011-02-19 19:51                         ` Nasser M. Abbasi
2011-02-19 22:36                           ` Anonymous
2011-02-19 22:45                             ` Nasser M. Abbasi
2011-02-20  0:55                               ` Nomen Nescio
2011-02-20  1:51                                 ` Nasser M. Abbasi
2011-02-20  9:49                                   ` Vinzent Hoefler
2011-02-18  7:07                   ` Chuck
2011-02-17 21:00             ` Yannick Duchêne (Hibou57)
2011-02-17 22:55               ` Georg Bauhaus
2011-02-18  3:09                 ` Yannick Duchêne (Hibou57)
2011-02-18  9:37                   ` Georg Bauhaus
2011-02-18 11:34             ` richard
2011-02-18 11:56               ` Georg Bauhaus
2011-02-18 13:26                 ` richard
2011-02-18 14:15                   ` Georg Bauhaus
2011-02-17 20:58           ` Yannick Duchêne (Hibou57)
2011-02-18  7:11             ` Chuck
2011-02-18 17:17               ` Paul Colin Gloster
2011-02-20  4:35                 ` Chuck
2011-02-18  7:16         ` Chuck
2011-02-18  7:27         ` Chuck
2011-02-18  7:28         ` Chuck
2011-02-17  3:41 ` Mike Sieweke
2011-02-17 13:31   ` Peter C. Chapin
2011-02-18  5:15     ` Mike Sieweke
2011-02-18  6:41       ` Chuck
2011-02-18  6:39     ` Chuck
2011-02-17 15:30   ` Hyman Rosen
2011-02-17 17:31     ` Martin
2011-02-17 19:12     ` Yannick Duchêne (Hibou57)
2011-02-17 18:51   ` Yannick Duchêne (Hibou57)
2011-02-18  6:45     ` Chuck
2011-02-18  6:38   ` Chuck
2011-02-17  8:31 ` Ludovic Brenta
2011-02-17  9:02   ` Dmitry A. Kazakov
2011-02-17 13:38     ` Peter C. Chapin
2011-02-17 16:12       ` Dmitry A. Kazakov
2011-02-17 16:25         ` Hyman Rosen
2011-02-17 17:46           ` Georg Bauhaus
2011-02-17 18:09             ` Hyman Rosen
2011-02-18  5:59               ` Chuck
2011-02-17 18:22           ` Dmitry A. Kazakov
2011-02-18  6:23           ` Chuck
2011-02-17 17:27         ` Peter C. Chapin
2011-02-17 18:46           ` Dmitry A. Kazakov
2011-02-18  6:15           ` Chuck
2011-02-18 13:37             ` Peter C. Chapin
2011-02-20  4:33               ` Chuck
2011-02-17 19:29         ` Yannick Duchêne (Hibou57)
2011-02-18  9:17           ` Dmitry A. Kazakov
2011-02-17 19:34         ` Yannick Duchêne (Hibou57)
2011-02-18  9:41           ` Dmitry A. Kazakov
2011-02-17 19:25       ` Yannick Duchêne (Hibou57)
2011-02-18  6:20       ` Chuck
2011-02-17 19:19     ` Yannick Duchêne (Hibou57)
2011-02-17 20:50       ` Georg Bauhaus
2011-02-17 21:08         ` Yannick Duchêne (Hibou57)
2011-02-18  0:13           ` Georg Bauhaus [this message]
2011-02-18  6:12         ` Chuck
2011-02-18  7:47           ` Yannick Duchêne (Hibou57)
2011-02-18  6:07     ` Chuck
2011-02-18 17:38       ` Paul Colin Gloster
2011-02-17 11:51 ` Ludovic Brenta
2011-02-17 20:47   ` Yannick Duchêne (Hibou57)
2011-02-20  4:41 ` Chuck
2011-02-20 10:28   ` Brian Drummond
2011-02-20 14:48   ` Britt Snodgrass
2011-10-04 20:51 ` Yannick Duchêne (Hibou57)
2011-10-04 21:00   ` Yannick Duchêne (Hibou57)
2011-10-05  1:53     ` Peter C. Chapin
2011-10-05  2:13       ` Yannick Duchêne (Hibou57)
2011-10-05  4:48         ` Jeffrey Carter
2011-10-05  6:21           ` Yannick Duchêne (Hibou57)
2011-10-05  6:39             ` Jeffrey Carter
2011-10-05  5:13         ` Niklas Holsti
2011-10-05  6:33           ` Yannick Duchêne (Hibou57)
2011-10-05  6:45             ` Jeffrey Carter
2011-10-08  1:36             ` Randy Brukardt
2011-10-08  8:39               ` Niklas Holsti
2011-10-08 23:11               ` Yannick Duchêne (Hibou57)
2011-10-06 13:19         ` Peter C. Chapin
2011-10-06 14:01           ` Hyman Rosen
2011-10-08  1:24       ` Randy Brukardt
2011-10-08 13:14         ` Peter C. Chapin
2011-10-08 17:49           ` Jeffrey Carter
2011-10-08 23:55           ` Yannick Duchêne (Hibou57)
2011-10-10 13:31             ` Paul Colin Gloster
2011-10-11  7:45               ` Yannick Duchêne (Hibou57)
2011-10-11  9:40                 ` SPARK and other provers (Was: Re: What's wrong with C++?) Phil Thornley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox