comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada.Locales pseudo-string types
Date: Wed, 8 Aug 2012 12:11:14 +0200
Date: 2012-08-08T12:11:14+02:00	[thread overview]
Message-ID: <vyin53dz9bfi.15xca328nh2fa$.dlg@40tude.net> (raw)
In-Reply-To: b24ee6f8-a552-4d1d-819c-0e3705d0a78e@googlegroups.com

On Wed, 8 Aug 2012 02:32:53 -0700 (PDT), Marius Amado-Alves wrote:

> I agree that letting contracts contain dynamics stuff brings us dangerously close to weak typing.
> 
> But let me recall that the original case is all static: we want to convert from
> 
>    type Language_Code is array (1 .. 3) of Character range 'a' .. 'z';
> 
> to
> 
>    type String is array(Positive range <>) of Character
>       with Pack;
> 
> Nothing could go wrong in this case.

That depends on the way you define wrongness. To me it is already wrong
because types are different. Note that from my POV being structurally
equivalent means nothing. Type is a set of values and operations. What
operations are defined on Language_Code? Are they same to ones of String?
If so, then conversion is possible. But I don't know it. It is not the
language business to determine.

Moreover, for non-tagged types it is broken anyway, because any
user-defined operations are not primitive and get ignored by the compiler
where you expected that least. There really should be no types without
classes and primitive operations.

If I ran the circus I would allow means to make Language_Code a proper
subtype of String while retaining necessary constraints.

Furthermore, regarding the points J-P. made, it is important to have
subtypes differently implemented. That would leave the issues of
optimization to the programmer's discretion. You would define a conversion
from Language_Code to String and use the former with any operations taking
in-String. You would declare a backward conversion and would use it with
all out-String operations. Two conversions more and you would be able to
use String with Language_Code operations.

> Or in the general case of converting from subranges to fullranges, no
> matter how deep in the type structure. If the structure is the same, and
> the operand has a subrange (or a match) in the same place as the target,
> then please (dear Ada 202X) convert it.

This is what I certainly disagree with. Structure is an implementation
detail.

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



  reply	other threads:[~2012-08-13  9:43 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 16:45 Ada.Locales pseudo-string types Marius Amado-Alves
2012-08-06 17:10 ` Marius Amado-Alves
2012-08-06 19:15   ` J-P. Rosen
2012-08-06 19:34     ` Simon Wright
2012-08-06 20:07       ` Marius Amado-Alves
2012-08-06 20:57         ` Simon Wright
2012-08-06 21:09           ` Vasiliy Molostov
2012-08-06 23:07             ` Adam Beneschan
2012-08-06 23:23               ` Vasiliy Molostov
2012-08-06 23:46                 ` Adam Beneschan
2012-08-07  1:17                   ` Vasiliy Molostov
2012-08-07  7:20               ` Dmitry A. Kazakov
2012-08-07  7:43               ` Jacob Sparre Andersen
2012-08-09 20:47                 ` Randy Brukardt
2012-08-07  8:44               ` Marius Amado-Alves
2012-08-07 13:14                 ` Marius Amado-Alves
2012-08-07 15:42                   ` Adam Beneschan
2012-08-07 18:22                     ` Marius Amado-Alves
2012-08-07 20:10                       ` Adam Beneschan
2012-08-07 20:42                         ` Marius Amado-Alves
2012-08-07 21:38                           ` Adam Beneschan
2012-08-08  7:04                           ` Niklas Holsti
2012-08-08  7:18                             ` Dmitry A. Kazakov
2012-08-08  7:37                               ` Niklas Holsti
2012-08-08  8:09                                 ` Dmitry A. Kazakov
2012-08-08 11:14                                   ` Niklas Holsti
2012-08-08 11:59                                     ` Dmitry A. Kazakov
2012-08-08 14:01                                       ` Niklas Holsti
2012-08-09  7:48                                         ` Dmitry A. Kazakov
2012-08-09  8:31                                           ` Niklas Holsti
2012-08-09 12:17                                             ` Dmitry A. Kazakov
2012-08-09 15:25                                               ` Niklas Holsti
2012-08-09 16:43                                                 ` Dmitry A. Kazakov
2012-08-08  8:28                                 ` J-P. Rosen
2012-08-08 11:35                                   ` Niklas Holsti
2012-08-08 14:05                                     ` Georg Bauhaus
2012-08-08  7:32                             ` J-P. Rosen
2012-08-08  8:17                               ` Niklas Holsti
2012-08-08  8:33                                 ` J-P. Rosen
2012-08-08 11:44                                   ` Niklas Holsti
2012-08-09 21:00                                   ` Randy Brukardt
2012-08-08  8:35                                 ` Dmitry A. Kazakov
2012-08-08  9:32                                   ` Marius Amado-Alves
2012-08-08 10:11                                     ` Dmitry A. Kazakov [this message]
2012-08-08 11:28                                       ` Marius Amado-Alves
2012-08-08 11:30                                         ` Marius Amado-Alves
2012-08-08 11:35                                       ` Marius Amado-Alves
2012-08-08 12:24                                         ` Dmitry A. Kazakov
2012-08-08 11:52                                   ` Niklas Holsti
2012-08-08 13:21                                     ` Dmitry A. Kazakov
2012-08-08  9:07                             ` Marius Amado-Alves
2012-08-07 20:43                         ` Marius Amado-Alves
2012-08-07 21:59                   ` Robert A Duff
2012-08-07 22:19                     ` Adam Beneschan
2012-08-08  0:37                       ` Robert A Duff
2012-08-07 15:26                 ` Adam Beneschan
2012-08-07 18:07                   ` Marius Amado-Alves
2012-08-07 17:51       ` Simon Wright
2012-08-06 20:00     ` Marius Amado-Alves
2012-08-06 19:49   ` Jacob Sparre Andersen
2012-08-06 20:11     ` Marius Amado-Alves
2012-08-06 17:37 ` Michael Rohan
2012-08-06 18:23   ` Marius Amado-Alves
2012-08-06 19:36     ` Michael Rohan
2012-08-09 21:15   ` Randy Brukardt
2012-08-07  5:57 ` Jeffrey R. Carter
2012-08-07 15:46   ` Adam Beneschan
2012-08-07 17:51     ` Jeffrey R. Carter
2012-08-09 21:17       ` Randy Brukardt
replies disabled

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