comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: Implementation of "=" (Ada83)
Date: 1996/07/15
Date: 1996-07-15T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96Jul14214833@organon.com> (raw)
In-Reply-To: mheaney-1307961304430001@news.ni.net


In article <mheaney-1307961304430001@news.ni.net> mheaney@ni.net (Matthew Heaney) writes:

> There's one other implementation technique I thought of, that I don't
> really like, but here it is:

> package T_Package is
> 
> ...
> 
> private
> 
>    type T_Representation is
>       record
>          A, B : Integer;
>       end record;
> 
>    type T is new T_Representation;
> 
> end;
> 
> package body T_Package is
> 
>    function "=" (L, R : T) return Boolean is
>    begin
>       return T_Representation (L) = T_Representation (R);
>    end;
> 
> end;

This should work in both Ada83 and Ada95.  Why don't you like it.  Well,
OK, maybe it isn't the most aesthetic thing, but this is kind of a "gotcha"
in the language and you probably can't expect anything really clean...

> Can anyone out there explain how they would implement the "=" for T?

Probably as above.  The trick is you have to separate the type definition
from the implementation.  Another hack would be:

private
     type T_Rep is ...

     type T is record
         The_Impl : T_Rep;
     end record;
...

    return L.The_Impl = R.The_Impl;


/Jon

-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





      reply	other threads:[~1996-07-15  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-13  0:00 Implementation of "=" (Ada83) Matthew Heaney
1996-07-15  0:00 ` Jon S Anthony [this message]
replies disabled

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