On 2022-06-24 10:10, L. B. wrote:
type my_float is new float;
function "=" (left, right : in my_float) return boolean is begin
....
end "="
a, b : my_float;
a := 0.01
b := 0.009;
-- 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 ?
With a derived type like this, you can convert back to the parent type:
if Float (A) = Float (B) then
With a completely new type, you can only name one of the operations "=". You have to decide which one you want to call "=", and which one you want to call something else, like Equal. So, for
type Real is digits 7;
you can either call your new operation Equal
function Equal (Left : in Real; Right : in Real) return Boolean;
which leave "=" for the predefined operation, or you can rename the predefined operation to Equal as Kazakov has described
function Equal (Left : in Real; Right : in Real) return Boolean renames "="; function "=" (Left : in Real; Right : in Real) return Boolean;
--
Jeff Carter
"[I]t is foolish to polish a program beyond the
point of diminishing returns, but most programmers
do too little revision; they are satisfied too
early."
Elements of Programming Style
189
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)