comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada.Locales pseudo-string types
Date: Wed, 08 Aug 2012 14:35:15 +0300
Date: 2012-08-08T14:35:15+03:00	[thread overview]
Message-ID: <a8f17iF9j2U1@mid.individual.net> (raw)
In-Reply-To: <jvt7ue$sgl$1@dont-email.me>

On 12-08-08 11:28 , J-P. Rosen wrote:
> Le 08/08/2012 09:37, Niklas Holsti a �crit :
> 
>> But we are talking about explicitly requested type conversions, not
>> implicit type equivalence. As I understood it, at least.
> Yes, or more precisely, about the special rules for array conversions,
> which are allowed if the types are structurally "close enough".
>>
>>>> For a value conversion,
>>>> the default could be to convert element by element, and the compiler
>>>> could then optimize this conversion based on what it can deduce
>>>> statically about the matching of the source and target subtypes.
>>>
>>> Could be interesting when elements themselves are arrays of discriminated
>>> record subtypes constrained via discriminants with array components again
>>> constrained etc.
>>
>> Sure, but this should not require much new intelligence in the compiler.
>> An array type conversion of the form A1 := A1_Type(A2); could just as
>> well be written as an explicit loop with explicit element-by-element
>> conversions, A1(I) := A1_Element_Type(A2(I)). A compiler could do this
>> expansion internally, giving code that is legal today and which the
>> compiler should already be able to compile.
>>
> That's the whole point: a possible costly loop implicitely generated by
> the compiler. The design choice was to /not/ hide this, i.e. allow array
> conversions only when no extra code was required.

But such implicit loops can already be generated in several places, for
example in the assignment of array values and in the application of
relational or Boolean operators to arrays. So this design choice has not
been applied uniformly.

> You are free to disagree with that design choice, of course...

I don't agree or disagree; it is a trade-off between ease of expression
and simplicity of the resulting code. The all-or-nothing language design
choices of early Ada, e.g. the "no subsets" rule, have given place to
more flexibility, exemplified by configuration pragmas such as pragma
Restrictions.

In my professional area (worst-case execution-time analysis),
compiler-generated implicit loops are often a problem, especially in Ada
programs. A restriction identifier to forbid such loops (at least when
the number of iterations is dynamic) could be useful here, and would let
programmers choose between a restrictive or a permissive coding style.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  reply	other threads:[~2012-08-13  8:51 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 [this message]
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
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