comp.lang.ada
 help / color / mirror / Atom feed
* Questions on an 83->95 porting detail
@ 1997-01-24  0:00 W. Wesley Groleau (Wes)
  1997-01-25  0:00 ` Robert A Duff
  1997-01-27  0:00 ` Keith Allan Shillington
  0 siblings, 2 replies; 3+ messages in thread
From: W. Wesley Groleau (Wes) @ 1997-01-24  0:00 UTC (permalink / raw)



Yes, I've seen the answers in print, but I'm having trouble finding it
again... :-)

1. Since a NOTE is not a rule, but only a "consequence of [a] rule
defined elsewhere," what is/are the rule(s) that 12.5.1(28) is a
consequence of?  12.5.1(17) says I need a member of the "class of
all types" but 12.5.1(28) says, "No, you need a member of the
class of all definite types."

2. What is the smallest change to the Ada-83 code for
Heap_Management.Unconstrained so that all of its clients will compile
with Ada 95?  (I'd prefer to change the first generic instead of
over fifty instantiations!)

3. What would be the minimum change to the same code so that all its
clients will work properly with Ada 95?

4. Extra credit if the result is still legal, working Ada-83.... :-)

* heap_management.ads contains:

  generic
    type Item is limited private;
    type Pointer is access Item;
  package Unconstrained is
  -- intended to be used for unconstrained types
  -- an alternate, more efficient, version is offered for constrained types


* string_sequential_limited_unbounded_managed_iterator.ads starts out:

generic
  type Item is limited private;
  type Substring is array (Positive range <>) of Item;

* it also includes:

private
  type Structure is access Substring;


* string_sequential_limited_unbounded_managed_iterator.adb contains:

  package Heap_Management_Operations is
      new Heap_Management.Unconstrained    -- line 42
              (Item => Substring,
               Pointer => Structure);

* gcc makes this complaint:

string_sequential_limited_unbounded_managed_iterator.adb: 42:24:
                          actual for "Item" must be a definite subtype

---------------------------------------------------------------------------
W. Wesley Groleau (Wes)                                Office: 219-429-4923
Hughes Defense Communications (MS 10-41)                 Home: 219-471-7206
Fort Wayne,  IN   46808                  (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions on an 83->95 porting detail
  1997-01-24  0:00 Questions on an 83->95 porting detail W. Wesley Groleau (Wes)
@ 1997-01-25  0:00 ` Robert A Duff
  1997-01-27  0:00 ` Keith Allan Shillington
  1 sibling, 0 replies; 3+ messages in thread
From: Robert A Duff @ 1997-01-25  0:00 UTC (permalink / raw)



In article <9701242001.AA16557@most>,
W. Wesley Groleau (Wes) <wwgrol@PSESERV3.FW.HAC.COM> wrote:
>Yes, I've seen the answers in print, but I'm having trouble finding it
>again... :-)
>
>1. Since a NOTE is not a rule, but only a "consequence of [a] rule
>defined elsewhere," what is/are the rule(s) that 12.5.1(28) is a
>consequence of?

The first sentence follows from the fact that there's no rule forbidding
it.  The second sentence follows from 12.5.1(6).  (By the way, in many
cases the AARM can help answer this sort of question.  Not in this case,
though, unless you consider 12.5.1(6.a) to be helpful.)

>...  12.5.1(17) says I need a member of the "class of
>all types"

Yes, and you do.

>... but 12.5.1(28) says, "No, you need a member of the
>class of all definite types."

That doesn't make sense -- there's no such thing as "the class of all
definite types", because "definite" is an adjective describing subtypes,
not types.  The actual *type* has to be in a certain class determined by
the formal, and the actual *subtype* has to be definite if the formal
has no discrim_part.  Two separate requirements.

(It's not hard to get confused between types and subtypes, since there's
something that looks like "type T is ...", and that thing is called a
type_declaration, but it does *not* declare a type called T.  That's
ridiculous, IMHO.  One of several cases in which Ada's terminology is
truly awful.)

>2. What is the smallest change to the Ada-83 code for
>Heap_Management.Unconstrained so that all of its clients will compile
>with Ada 95?  (I'd prefer to change the first generic instead of
>over fifty instantiations!)

Add an unknown_discriminant_part:

    type Item(<>) is limited private;

>3. What would be the minimum change to the same code so that all its
>clients will work properly with Ada 95?

See above.

>4. Extra credit if the result is still legal, working Ada-83.... :-)

Sorry, I don't get the extra credit -- the unknown_discrim_part is
needed in Ada 95, but illegal in Ada 83.  Sigh.

- Bob




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions on an 83->95 porting detail
  1997-01-24  0:00 Questions on an 83->95 porting detail W. Wesley Groleau (Wes)
  1997-01-25  0:00 ` Robert A Duff
@ 1997-01-27  0:00 ` Keith Allan Shillington
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Allan Shillington @ 1997-01-27  0:00 UTC (permalink / raw)



W. Wesley Groleau (Wes) <wwgrol@PSESERV3.FW.HAC.COM> wrote in article
<9701242001.AA16557@most>...

> 1. Since a NOTE is not a rule, but only a "consequence of [a] rule
> defined elsewhere," what is/are the rule(s) that 12.5.1(28) is a
> consequence of?  12.5.1(17) says I need a member of the "class of
> all types" but 12.5.1(28) says, "No, you need a member of the
> class of all definite types."

That would be 12.5.1(7) and 12.5.1(11) Where the difference between a
formal with and without a discriminant.  Actually the key wording is at
12.5.1(6) "If the formal subtype is definite, then the actual subtype shall
also be definite."  So, 12.5.1(28) is a direct result of 12.5.1(6)

> 2. What is the smallest change...
see below
> 3. What would be the minimum change...
see below 
> 4. Extra credit if the result is still legal, working Ada-83.... :-)

No can do.

> * heap_management.ads contains:
> 
>   generic
>     type Item is limited private;
      type Item is limited private (<>);
>     type Pointer is access Item;
>   package Unconstrained is
>   -- intended to be used for unconstrained types
>   -- an alternate, more efficient, version is offered for constrained
types

Given the comment in the package spec, this software is designed to allow
for the unknown discriminant.  Ada95 requires that you inform the compiler
of this design decision.  Sadly, your Ada83 compiler will not recognize
this new syntax.

-- Keith Shillington keith@sd.aonix.com




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-01-27  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-24  0:00 Questions on an 83->95 porting detail W. Wesley Groleau (Wes)
1997-01-25  0:00 ` Robert A Duff
1997-01-27  0:00 ` Keith Allan Shillington

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