From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f47e0c6e2e5fd00d X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Function name problem Date: 2000/01/17 Message-ID: #1/1 X-Deja-AN: 573577579 Content-transfer-encoding: 7bit References: <85qecu$24r$1@nnrp1.dej a.com> <01qg4.3200$%Y3.193028@newsread2. prod.itd.earthlink.net> Content-Type: text/plain; charset="US-ASCII" X-ELN-Date: Sun Jan 16 18:37:32 2000 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 948076652 38.26.192.202 (Sun, 16 Jan 2000 18:37:32 PST) Organization: EarthLink Network, Inc. Mime-version: 1.0 NNTP-Posting-Date: Sun, 16 Jan 2000 18:37:32 PST Newsgroups: comp.lang.ada Date: 2000-01-17T00:00:00+00:00 List-Id: In article , Harald Schmidt wrote: > ...my intenstion was not to implement a functional operator > equivalent to C/C++. My primary business is Smalltalk, and > I was trying to implement the equal method "=", means > equality of any attribute of two given objects. The second > method "==" (basis for this discussion) is a identity > method comparing the identity of two given objects. OK. Smalltalk has reference semantics. To implement a by-reference type in Ada(95), use access types. "Comparing identity" in Ada95 means comparing access objects. package P is type T (<>) is abstract tagged limited null record; type TA is access all T'Class; function "=" (L, R : T) return Boolean is abstract; procedure Op (O : access T) is abstract; end P; package P.C is type NT is new T with private; function New_NT return TA; procedure Op (O : access NT); function "=" (L, R : NT) return Boolean; private type NT is new T with record ...; ... end P.C; A client of a by-reference abstraction declares an access object, and then calls the constructor for the type: declare O1, O2 : TA := New_NT; begin ... if O1.all = O2.all then -- compare values if O1 = O2 then -- compare identities In neither case do you require an "==" operator. -- "I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use." Galileo Galilei