comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Function name problem
Date: 2000/01/15
Date: 2000-01-15T00:00:00+00:00	[thread overview]
Message-ID: <pg3g4.1372$541.76317@newsread1.prod.itd.earthlink.net> (raw)
In-Reply-To: B4A633AE.3FF3%Harald.Schmidt@tomcat.de

In article <B4A633AE.3FF3%Harald.Schmidt@tomcat.de> , Harald Schmidt 
<Harald.Schmidt@tomcat.de>  wrote:

> I want to declare two function, but the 2nd is not
> allowed by GNAT3.12. Could someone tell me why?
> Here are the two declarations:
>
> package bla is
>     type Object is tagged limited private;
>     function "=" (Left, Right: in Object�Class) return Boolean;
>     function "==" (Left, Right: in Object�Class) return Boolean;
> private
>     type Object is tagged limited null record;
> end bla;

There is no "==" operator in Ada.

In Ada, "=" means "equality" (not assignment).

If you want to override assignment for a type, you must declare the type
as nonlimited and derive from Controlled:

with Ada.Finalization;
package P is

  type T is private;

  function "=" (L, R : T) return Boolean;  -- equality

  <other ops>

private

  type T is new Ada.Finalization.Controlled with record
    ...
  end record;

  procedure Adjust (O : in out T);

  procedure Finalize (O : in out T);

end P;


You don't have the assignment operator for limited types.  In that case,
declare an explicity Copy operation.


--
You cannot think without abstractions; accordingly, it is of the utmost
importance to be vigilant in critically revising your modes of
abstraction.  It is here that philosophy finds its niche as essential to
the healthy progress of society.  It is the critic of abstractions.

Alfred North Whitehead




      parent reply	other threads:[~2000-01-15  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-15  0:00 Function name problem Harald Schmidt
2000-01-15  0:00 ` Jeff Carter
2000-01-16  0:00   ` Harald Schmidt
2000-01-16  0:00     ` David Starner
2000-01-16  0:00       ` David C. Hoos, Sr.
2000-01-16  0:00         ` David Starner
2000-01-18  0:00         ` Howard W. LUDWIG
2000-01-16  0:00       ` David A. Cobb
2000-01-16  0:00         ` David Starner
2000-01-17  0:00           ` David A. Cobb
2000-01-17  0:00             ` David Starner
2000-01-17  0:00               ` Jeff Carter
2000-01-16  0:00     ` Matthew Heaney
2000-01-16  0:00       ` Harald Schmidt
2000-01-16  0:00         ` Gautier
2000-01-17  0:00         ` Matthew Heaney
2000-01-26  0:00       ` Florian Weimer
2000-01-15  0:00 ` Pascal Obry
2000-01-15  0:00 ` Matthew Heaney [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