comp.lang.ada
 help / color / mirror / Atom feed
From: Vincent Marciante <marciant@li.net>
Subject: Re: Redefined "=" = generic disaster?
Date: 2000/10/21
Date: 2000-10-21T00:00:00+00:00	[thread overview]
Message-ID: <39F1DCFD.3276@li.net> (raw)
In-Reply-To: 39F1C092.87D4135E@acm.org

Jeff Carter wrote:
> 
> Vincent Marciante wrote:
> > generic
> >     type Something is private;
> > package Ada_83_Abstract_Data_Type is
> >     type ADT is private;
> >     ...
> >     function Is_Equal (L,R: ADT) return Boolean;

    private
        type ADT is ... composite type containing "Something"

> > end;
> > package body Ada_83_Abstract_Data_Type is
> >     ...
> >     function Is_Equal (L,R: ADT) return Boolean;

        function Is_Equal (L,R: ADT) return Boolean is

> >     begin
> >         return L = R;
            return <something part of L> = <something part of R>;

> >     end;
> > end;
> 
> This is not valid Ada 83. Assuming we add a private part to the spec and
> replace the ";" after "Boolean" with " is" in the body, you are invoking
> the predefined "=" on the local type ADT, not the generic formal type
> Something. Since we don't know the full definition of ADT, we don't know
> what this has to do with "=" for Something. If ADT is a composite type
> with one or more components of type Something, then "=" for ADT is
> defined (at least partly) in terms of the predefined "=" for Something.

Yes!! Your assuming was much better than my typing ;)  (Very punny!;)

> 
> > BTW, I not interested in arguments that the old Ada 83 code was actually
> > incorrect when it first written.  I am interested in finding out wats to
> > update it so that it works as one would expect ;) in Ada 95.
> 
> Any generic that uses "=" for a generic formal type should explicitly
> import "=" for the type:

Ugh!  So _are_ you saying that the Ada 83 code was defective wrt. Ada
83?

> 
> generic -- Some_Package
>    type T is private;
>    with function "=" (Left : T; Right : T) return Boolean is <>;
> package Some_Package is
> ...
> 
> > think of now is ethier add
> >
> >   function "=" (L,R: Private_Type) return Boolean is "=";
> 
> The construct
> 
>    is "="
> 
> on a generic formal function (note that you need "with" before
> "function") refers to a function named "=" that is visible when the
> generic is compiled. Such a function is unlikely to exist for a generic
> formal private type. To refer to a function "=" that is visible when the
> generic is instantiated, which is probably what you wanted, use
> 
>    is <>
> 
> instead.

Okay, yeah, that actually is what I had used.

> 
> > P.S. Wow its late, I hope (all/most;) of the above makes sense!

> 
> Possibly.
> 
> --
> Jeff Carter
> "I waggle my private parts at your aunties."
> Monty Python & the Holy Grail




  parent reply	other threads:[~2000-10-21  0:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-21  6:59 Redefined "=" = generic disaster? Vincent Marciante
2000-10-21  0:00 ` Jeff Carter
2000-10-21  0:00   ` Vincent Marciante
2000-10-28 11:12     ` Robert Dewar
2000-10-29  8:43       ` Vincent Marciante
2000-10-30  3:49       ` Lao Xiao Hai
2000-10-30 18:46         ` Robert Dewar
2000-10-31  3:27           ` Lao Xiao Hai
2000-10-31  6:54             ` Vincent Marciante
2000-10-31 19:51             ` Robert Dewar
2000-11-01 17:47               ` Mats Weber
2000-11-02  5:27                 ` Vincent Marciante
2000-11-02 16:52                   ` Mats Weber
2000-11-02 14:59                 ` Tucker Taft
2000-11-05  4:29                   ` Robert Dewar
2000-11-05  4:32                   ` Robert Dewar
2000-11-05  4:26                 ` Robert Dewar
2000-10-21  0:00   ` Vincent Marciante [this message]
2000-10-22  2:50     ` Jeff Carter
2000-10-22  0:00       ` Vincent Marciante
replies disabled

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