comp.lang.ada
 help / color / mirror / Atom feed
From: Markus E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: Ada generics
Date: Fri, 22 Dec 2006 18:33:11 +0100
Date: 2006-12-22T18:33:11+01:00	[thread overview]
Message-ID: <u5hcvnygx4.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: 1166805696.291429.239590@48g2000cwx.googlegroups.com


"Hyman Rosen" <hyman.rosen@gmail.com> writes:

> In any case, it's never been clear to me why constraints on generic
> parameters are considered to be so important by some people. Why not
> let templates be instantiated with anything the caller likes? In C++,
> if the parameters fail to satisfy some requirement in the template,
> then the compilation will fail. If the compilation succeeds, then you
> have a working instantiation. It's more likely that a constraint will
> prevent an unforeseen but valid usage from working than that it will
> catch some kind of error.

The same kind of argument could be applied to type systems:

 | In any case, it's never been clear to me why typing is considered
 | to be so important by some people ... It's more likely that a type
 | will prevent an unforeseen but valid usage from working than that
 | it will catch some kind of error.

I think the purpose is not "catching errors" but more likely
delivering abstraction. A constraint gives rules how a user of
reusable component have to use the component and thus reserve freedom
for future implementation changes: "You have to use the compoment like
this. Other usages would perhaps work with the present implementation,
but we don't want to guarantee for future implementations. We might
want to change implementation." That basically is the other side of
the contract offered to the component users by the component
developers.

C++ templates are something like: If it links and if it works then
it's OK, if not, bad luck. That is not a contract, just the license to
abuse a given implementation. And the license top break any existing
implementation.


>> 3. Generic object parameters can have any type (in C++ you cannot use
>> float, for example)
>
> Just a note on the float constraint. C++ considers instantiations
> identical if their parameters are identical, and introducing floating
> point can lead to ambiguities that the language designers chose to
> avoid by fiat. It's just the usual floating point issues, e.g., is
> 1.0/3.0*3.0 the same as 1.0? On which platforms?

Which just goes to show how evil that approach is.

Regards -- Markus




  reply	other threads:[~2006-12-22 17:33 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-21 14:14 Ada generics markww
2006-12-21 15:42 ` Dmitry A. Kazakov
2006-12-22  7:59   ` Martin Krischik
2006-12-22 16:14     ` Hyman Rosen
2006-12-22  7:59   ` Martin Krischik
2006-12-22 16:41   ` Hyman Rosen
2006-12-22 17:33     ` Markus E Leypold [this message]
2006-12-22 18:26       ` Hyman Rosen
2006-12-22 20:59         ` Markus E Leypold
2006-12-22 21:01           ` Markus E Leypold
2006-12-23 14:09           ` Marco
2006-12-25 14:23             ` Hyman Rosen
2006-12-29 14:13               ` Marco
2006-12-25 14:20           ` Hyman Rosen
2006-12-23 11:43     ` Dmitry A. Kazakov
2006-12-25 13:49       ` Hyman Rosen
2006-12-25 14:39         ` Dmitry A. Kazakov
2006-12-26  1:34           ` Hyman Rosen
2006-12-26  9:11             ` Dmitry A. Kazakov
2006-12-26 16:23               ` Hyman Rosen
2006-12-26 19:28                 ` Dmitry A. Kazakov
2006-12-27  1:44                   ` Hyman Rosen
2006-12-27  9:21                     ` Dmitry A. Kazakov
2006-12-27 19:06                       ` Hyman Rosen
2006-12-28 10:59                         ` Dmitry A. Kazakov
2006-12-28 16:29                           ` Hyman Rosen
2006-12-29 11:12                             ` Dmitry A. Kazakov
2006-12-29 14:56                               ` Hyman Rosen
2006-12-28 17:35                           ` Georg Bauhaus
2006-12-29 14:48                             ` Dmitry A. Kazakov
2006-12-29 19:39                               ` Georg Bauhaus
2006-12-30  9:58                                 ` Dmitry A. Kazakov
2006-12-30 14:53                                   ` Georg Bauhaus
2007-01-01 13:00                                     ` Dmitry A. Kazakov
2007-01-02 10:04                                       ` Georg Bauhaus
2007-01-02 11:11                                         ` Dmitry A. Kazakov
2007-01-02 12:33                                           ` Georg Bauhaus
2007-01-02 13:51                                             ` Dmitry A. Kazakov
2007-01-02 14:45                                               ` Georg Bauhaus
2007-01-03 10:10                                                 ` Dmitry A. Kazakov
2007-01-03 14:20                                                   ` Hyman Rosen
2007-01-03 14:55                                                   ` Georg Bauhaus
2007-01-04 10:15                                                     ` Dmitry A. Kazakov
2007-01-03 19:33                                           ` Alexander E. Kopilovich
2007-01-04 10:27                                             ` Dmitry A. Kazakov
2007-01-04 15:00                                               ` Alexander E. Kopilovich
2007-01-05 10:32                                                 ` Dmitry A. Kazakov
2006-12-30  2:25                               ` Randy Brukardt
2006-12-30 10:13                                 ` Dmitry A. Kazakov
2007-01-04  1:09                                   ` Randy Brukardt
2007-01-04 10:07                                     ` Dmitry A. Kazakov
2007-01-05  1:32                                       ` Randy Brukardt
2007-01-05  4:46                                         ` Randy Brukardt
2007-01-05  9:08                                         ` Jean-Pierre Rosen
2007-01-05 20:14                                         ` Georg Bauhaus
2007-01-06  0:14                                           ` Randy Brukardt
2006-12-29  0:09                           ` Randy Brukardt
2006-12-29 11:11                             ` Dmitry A. Kazakov
2006-12-30  2:40                               ` Randy Brukardt
2006-12-21 16:55 ` Hyman Rosen
2006-12-21 18:22   ` markww
2006-12-22  3:01 ` Steve
replies disabled

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