TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Subject:
From:
Tucker Taft <[log in to unmask]>
Date:
Thu, 16 Jul 1998 10:12:55 -0400
X-To:
Reply-To:
Tucker Taft <[log in to unmask]>
Parts/Attachments:
text/plain (45 lines)
> > in both of your solutions, you assumed that the
> > "and"-function is defined even
> > for the array type. But you didn't define that function like e.g.
>
> This is untrue, see RM 4.5.1(6).
>
> Actually the original program (the second variant with Standard."and")
> works correctly with the GNAT compiler (but not with ObjectAda).

But that is a bug in GNAT.

The predefined "and" is *not* declared in package Standard (despite what
GNAT things ;-).  It is declared where the array type is
declared.  However, because there is a matching user-defined "and"
declared immediately in the same scope, the predefined
"and" is not visible.  The suggested fix, with a separate
array type, and then a definition of the private type
as being derived from that, works.

Another approach that works is to declare an array type local to
the body of "and", and convert to that.  That works because
array conversion works between unrelated array types, presuming
they are structurally equivalent.

Note that the desire to export some but not all of the predefined
operators of the full type for a private type is a frequent one,
and has been discussed a fair bit in the past.  We imagined various
"magic" syntaxes, such as:

    function "and"(left, right : the_type) return the_type renames <>;

where in this case, "<>" stands for the hidden predefined definition.
However, lacking such "magic" language constructs, you are generally
stuck using derived types, multiple renames, etc.

> -Stephane

-Tucker Taft  [log in to unmask]
>
> ----
> Stephane Barbey, PhD   phone: +41(31)828.92.17
> Paranor AG             fax:   +41(31)828.92.99
> 3046 Wahlendorf            [log in to unmask]
> Switzerland      http://lglwww.epfl.ch/~barbey

ATOM RSS1 RSS2