comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Reconsidering assignment
Date: Mon, 11 Jun 2007 15:09:35 +0200
Date: 2007-06-11T15:06:59+02:00	[thread overview]
Message-ID: <1xa921mmvtl1s$.bi071usuglx4$.dlg@40tude.net> (raw)
In-Reply-To: 1181552659.785072.44010@p77g2000hsh.googlegroups.com

On Mon, 11 Jun 2007 02:04:19 -0700, Maciej Sobczak wrote:

> On 10 Cze, 11:21, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>>>> New subtypes can also be obtained through generalization, i.e. by lifting
>>>> constraints.
>>
>>> Yes, but then they are not SUBtypes. :-)
>>
>> subtype /= subset. Especially if you consider Liskov-Wing definitions. They
>> defines it in terms of substitutability. A more pragmatic definition would
>> be:
>>
>> S is a subtype of T in an operation f when S inherits the interface of f.
> 
> I don't see how this might imply anything. If f cares about
> preconditions on its arguments, then being a subtype means being a
> subset (and if f doesn't care about preconditions then there is little
> sense in implying any relation between T and S based on f).

1. Ada and other languages have subtypes, but to preconditions.

2. Program correctness (if you meant that following Liskov-Wing) has
nothing to do with subtyping. Correctness is a property of a given program.
Subtyping is a relation between types in a program, which occasionally
might be correct or incorrect. They tried to bind them and failed, because
types systems are too weak to express correctness.

But anyway, the domain sets of the types need not to be proper subsets of
each other in any of these two definitions. There might be some mapping
required, but no more than that. Consider Cartesian product, it is LSP
compatible. (Example: Ellipse inheriting x-axis from Circle).

> Lifting constraints doesn't give subtypes.

LSP certainly does. For example, int is a proper LSP subtype of const int.
Adding constraints is much more offending for LSP subtyping than lifting,
because it breaks in-operations, which are more common.

>>> BTW - the fact that I cannot make a subtype by selecting non-
>>> contiguous subranges of enum values is really disappointing.
>>
>> That is because you cannot inherit "..", 'Succ and 'Pred. To have
>> non-contiguous enumerations, you should have them as a base type/interface
>> first.
> 
> Yes, this is what I expect:
> 
> type Color is (Black, Red, Green, Blue, White);
> 
> I don't want any "..", 'Succ nor 'Pred here.

Then you should understand why I am arguing against that hard-wired stuff
(which includes assignment) in favor of abstract interfaces (of unordered /
ordered enumerations and whatever else). People designing Ada's
"enumeration class" considered some semantics to be applicable in all
cases. You do same presuming that ":=" has some God-written properties.

> No. Compile-time expression is not executed in the universe of
> functions overloaded in the program. It can use completely separate
> rules - what matters is the result and whether it fits in the given
> type.

Yuck, how many languages would you have in one? I don't want it. I want a
small regular predictable language.
 
> Then let's make the constraint part of the type.

In that case you will be unable to write programs where that part could
vary.

One of the great contributions Ada made to typed systems was dynamically
constrained types and generic programming in terms of those types. We need
not to go back to Pascal.

>> If you want to distinguish something between legal and an illegal
>> you need different types. Legality cannot depend on a constraint.
> 
> The whole point of my speculations is to elevate constraints to the
> level where they could take part in legality resolutions. I hoped it
> was clear.

but failed to propose a framework for that. Honestly, it is a very complex
problem of how to enforce statically known constraints to be evaluated at
compile time. Once solved, it would immensely simplify the language and the
libraries of. But beware, it might make generics useless! (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-06-11 13:09 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06 21:33 Reconsidering assignment Maciej Sobczak
2007-06-06 22:52 ` Ray Blaak
2007-06-07  7:15   ` Maciej Sobczak
2007-06-07 16:34     ` Ray Blaak
2007-06-07  7:10 ` Stefan Lucks
2007-06-07  7:32   ` Maciej Sobczak
2007-06-07 11:11     ` Stefan Lucks
2007-06-07 16:28   ` Ray Blaak
2007-06-07  9:27 ` Dmitry A. Kazakov
2007-06-07 16:54   ` contracted exceptions (was Re: Reconsidering assignment) Ray Blaak
2007-06-07 20:04     ` contracted exceptions Robert A Duff
2007-06-07 21:11       ` Ray Blaak
2007-06-07 23:44         ` Robert A Duff
2007-06-08  2:19       ` Randy Brukardt
2007-06-08  7:39         ` Dmitry A. Kazakov
2007-06-08  8:53           ` Ray Blaak
2007-06-08 12:08             ` Dmitry A. Kazakov
2007-06-08 17:31               ` Ray Blaak
2007-06-08 18:00                 ` Dmitry A. Kazakov
2007-06-08 18:20                   ` Georg Bauhaus
2007-06-08 18:56                     ` Dmitry A. Kazakov
2007-06-08 19:15                   ` Simon Wright
2007-06-09  0:14                     ` Randy Brukardt
2007-06-09  2:44                       ` Larry Kilgallen
2007-06-09  8:21                     ` Dmitry A. Kazakov
2007-06-09 12:32                       ` Simon Wright
2007-06-09 18:38                         ` Dmitry A. Kazakov
2007-06-09 21:04                           ` Simon Wright
2007-06-10  9:21                             ` Dmitry A. Kazakov
2007-06-10 11:49                               ` Simon Wright
2007-06-10 15:20                                 ` Dmitry A. Kazakov
2007-06-11  4:13                                   ` Ray Blaak
2007-06-11  7:58                                     ` Dmitry A. Kazakov
2007-06-11 17:06                                       ` Ray Blaak
2007-06-11 19:57                                         ` Dmitry A. Kazakov
2007-06-10 18:14                                 ` Georg Bauhaus
2007-06-10 18:12                               ` Georg Bauhaus
2007-06-11  7:55                                 ` Dmitry A. Kazakov
2007-06-11 14:15                         ` Bob Spooner
2007-06-11 15:14                           ` Georg Bauhaus
2007-06-11 15:20                             ` (see below)
2007-06-11 16:39                               ` Georg Bauhaus
2007-06-11 19:50                           ` Simon Wright
2007-06-08 11:26         ` Martin Krischik
2007-06-08 12:02         ` Robert A Duff
2007-06-08 11:22     ` contracted exceptions (was Re: Reconsidering assignment) Martin Krischik
2007-06-08 17:44       ` Ray Blaak
2007-06-08 12:10     ` contracted exceptions Robert A Duff
2007-06-08 15:56       ` Stefan Lucks
2007-06-08 20:27         ` Pascal Obry
2007-06-09  0:19           ` Randy Brukardt
2007-06-09 18:04             ` Robert A Duff
2007-06-09 18:37               ` Dmitry A. Kazakov
2007-06-09 20:43                 ` Robert A Duff
2007-06-10  9:21                   ` Dmitry A. Kazakov
2007-06-11 19:18                   ` Randy Brukardt
2007-06-12  6:55                     ` Jean-Pierre Rosen
2007-06-08 17:40       ` Ray Blaak
2007-06-09 18:14         ` Robert A Duff
2007-06-08 19:18       ` Simon Wright
2007-06-09 22:37   ` Reconsidering assignment Maciej Sobczak
2007-06-10  9:21     ` Dmitry A. Kazakov
2007-06-11  9:04       ` Maciej Sobczak
2007-06-11 13:09         ` Dmitry A. Kazakov [this message]
2007-06-11 18:57     ` Randy Brukardt
2007-06-11 21:12       ` Maciej Sobczak
2007-06-12  8:31         ` Dmitry A. Kazakov
2007-06-12  9:31           ` Georg Bauhaus
2007-06-12 10:03             ` Dmitry A. Kazakov
replies disabled

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