From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: overloading predefined operators
Date: Fri, 24 Jun 2022 10:23:48 +0200 [thread overview]
Message-ID: <t93sak$10r4$1@gioia.aioe.org> (raw)
In-Reply-To: 1fabca7a-e3f0-41bb-9b51-9eabde85e800n@googlegroups.com
On 2022-06-24 10:10, L. B. wrote:
> I have a question regarding redefining of operators like "=". My dummy code is:
>
> type my_float is new float;
>
> -- This overloads the predefined equality operation:
> function "=" (left, right : in my_float) return boolean is begin
> ....
> end "="
>
> a, b : my_float;
>
> a := 0.01
> b := 0.009;
>
> -- This test uses the overloading equality test:
> if a = b then -- uses the new "="
> null;
> end if;
>
> -- For some reasons I still need access to the overloaded original "=" function:
> if a = b then -- shall use the original "="
> null;
> end if;
>
> What can I do ?
Rename the inherited operation before killing it:
type M_Float is new Float;
function Equal (Left, Right : M_Float) return Boolean renames "=";
function "=" (Left, Right : M_Float) return Boolean;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next parent reply other threads:[~2022-06-24 8:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1fabca7a-e3f0-41bb-9b51-9eabde85e800n@googlegroups.com>
2022-06-24 8:23 ` Dmitry A. Kazakov [this message]
2022-06-24 9:44 ` overloading predefined operators L. B.
2022-06-25 3:18 ` Randy Brukardt
2022-06-25 5:58 ` L. B.
2022-06-25 6:21 ` G.B.
2022-06-24 10:47 ` Jeffrey R.Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox