comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782
Date: Mon, 22 Jan 2018 18:44:18 -0600
Date: 2018-01-22T18:44:18-06:00	[thread overview]
Message-ID: <p460h2$380$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: p3v378$1mqo$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:p3v378$1mqo$1@gioia.aioe.org...
> On 2018-01-20 01:42, Randy Brukardt wrote:
...
>> A type parameter clearly would have to pass the subtype information as 
>> well,
>
> Yes, like it does with array bounds, *if* it were a subprogram proper. 
> This is irrelevant because it is not a subprogram, it only has a syntax of 
> a subprogram call. But for the compiler it is a special case exactly like 
> it is when the attribute syntax is used, or any other syntax. The 
> detection does not require special syntax, that is the point. Once the 
> compiler detects the case, the magic starts to work.

Actually, a "special case" that uses typical syntax is not special at all, 
as a compiler has to start with recognizing and interpreting the normal 
syntax. In order to do that for Ada, one would have to have meta-types in 
order that the techniques would work with the resolution rules. It could be 
similar to the rules for universal_integer (needed to allow compile-time 
type-less expressions), but there would have to be something.

Yes, of course such special cases are not a problem for code 
generation/execution -- indeed, a "subprogram call" is just a mess of 
special cases to the point that there hardly is a "normal" case. (Remember 
that operators are "subprogram calls" in Ada, so many programs have more 
special cases than they do usual calls.)

...
>> (And I
>> don't see why you don't think it is related, either. One has to have some
>> mechanism for getting this information, and if you eliminate the special
>> mechanism for that, some replacement is needed. In the proposed language,
>> only a subprogram call is available, unless some other special syntax is
>> invented, which is just kicking the can.)
>
> It is the same mechanism used to pass/eliminate array bounds.

??? For Janus/Ada, at least, the array bounds ARE the object; the compiler 
only pays attention to the array data when it is directly accessed. (There 
is a pointer to the data stored with the bounds.) There is no separate 
"array bounds" mechanism; it is all tied to the subtype conversion 
mechanism.

One would need a separate mechanism to pass bounds by themselves -- not 
particular hard to do, but it would need a data type to represent "array 
bounds without any data".

> It could be generalized for all types including non-tagged classes. The 
> type tag of a non-tagged type is a [sub]type constraint to be passed or 
> not. The same case is represented by dimensioned values. The dimension is 
> a constraint, again passed or not down to the subprogram, kept or not in 
> an instance.
>
> I think it is possible to design common rules for all this and make the 
> language quite simple.

As before, I don't doubt this. I do doubt that it could be done with an 
acceptable level of compatibility. The additional overloading of subtypes 
needed would certainly cause ambiguities and care would have to be taken to 
avoid beaujolias effects.

If one was abandoning compatibility here altogether, then of course you are 
right -- and objects/exceptions should be overloadable to greatly reduce the 
visibility issues that come from use clauses -- and probably a dozen other 
minor fixes (like redoing renames so that static matching is required rather 
than ignoring the subtypes) should be done too. But that's not very likely 
to happen.

                                 Randy.





  reply	other threads:[~2018-01-23  0:44 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  1:18 ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782 Mehdi Saada
2018-01-15  3:23 ` Niklas Holsti
2018-01-15  8:29 ` Dmitry A. Kazakov
2018-01-15 10:49   ` Simon Wright
2018-01-15 11:51     ` Mehdi Saada
2018-01-15 12:00       ` Mehdi Saada
2018-01-15 13:32         ` Dmitry A. Kazakov
2018-01-15 18:55         ` Shark8
2018-01-15 13:51       ` Simon Wright
2018-01-15 15:18         ` Mehdi Saada
2018-01-15 15:29           ` Mehdi Saada
2018-01-15 15:50             ` Mehdi Saada
2018-01-15 17:53               ` Simon Wright
2018-01-15 17:22   ` Anh Vo
2018-01-15 17:48     ` Dmitry A. Kazakov
2018-01-15 19:56       ` Anh Vo
2018-01-16 16:06     ` Brian Drummond
2018-01-16 17:21       ` Anh Vo
2018-01-15 10:37 ` Simon Wright
2018-01-15 16:06 ` Mehdi Saada
2018-01-17 19:23   ` Niklas Holsti
2018-01-16 16:24 ` Mehdi Saada
2018-01-16 18:20   ` Jacob Sparre Andersen
2018-01-16 20:00     ` Mehdi Saada
2018-01-17 15:45 ` Mehdi Saada
2018-01-17 16:30   ` Dmitry A. Kazakov
2018-01-17 22:50     ` Mehdi Saada
2018-01-18  8:34       ` Dmitry A. Kazakov
2018-01-18 11:14         ` Simon Wright
2018-01-18 11:55           ` Dmitry A. Kazakov
2018-01-18 12:21             ` Mehdi Saada
2018-01-18 13:08               ` J-P. Rosen
2018-01-18 15:23                 ` Dmitry A. Kazakov
2018-01-19  1:10                   ` Randy Brukardt
2018-01-19  8:52                     ` Dmitry A. Kazakov
2018-01-20  0:42                       ` Randy Brukardt
2018-01-20  9:47                         ` Dmitry A. Kazakov
2018-01-23  0:44                           ` Randy Brukardt [this message]
2018-01-18 14:05         ` AdaMagica
2018-01-18 14:17           ` Mehdi Saada
2018-01-18 14:56             ` J-P. Rosen
2018-01-18 15:38               ` Mehdi Saada
2018-01-19  1:13                 ` Randy Brukardt
2018-01-18 16:48             ` AdaMagica
2018-01-18 16:59               ` Dmitry A. Kazakov
2018-01-18 19:36                 ` Mehdi Saada
2018-01-19  1:21                   ` Randy Brukardt
2018-01-19 16:15                 ` AdaMagica
2018-01-19 16:58                   ` Dmitry A. Kazakov
2018-01-21 23:27             ` G.B.
replies disabled

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