comp.lang.ada
 help / color / mirror / Atom feed
* Renaming Fixed Point Mutiplicative operator in Ada 95
@ 1998-05-19  0:00 Stuart Hutchesson
  1998-05-19  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 20+ messages in thread
From: Stuart Hutchesson @ 1998-05-19  0:00 UTC (permalink / raw)



In certain applications (notably safety critical systems) it is good
practise to supply protected maths operators (guarding against overflow
etc).  In these applications the use of floating point is sometimes  
frowned upon also and a common solution is to use fixed point types and
override/rename the mathematical operations.  

The following code fragment compiles on a number of Ada 83 systems
(VAX Ada, XDAda, ActivAda) and on GNAT 3.09 (Ada95)

package Test1 is

   type NewFixed is delta 0.01 range -1000.0 .. +1000.0;
 
   function MultFixed (LEFT : NewFixed; RIGHT : NewFixed) return
NewFixed ;
      
   procedure Test1DoIt;   

  
end Test1;


package body Test1 is
    
  function "*"   (LEFT  : NewFixed      ; RIGHT : NewFixed     ) return
NewFixed      renames Test1.MultFixed ;

  A1, A2, A3 : NewFixed;
  
  function MultFixed (LEFT : NewFixed; RIGHT : NewFixed) return NewFixed
is
  begin
    return 0.0;
  end MultFixed;
    
  procedure Test1DoIt is
  begin
    A1 := A2 * A3;
  end Test1DoIt;
  
end Test1;


However this is thrown out by ObjectAda saying the line A1 := A2*A3 is
ambiguous - it appears to match the context for the universal_fixed
multipication operator as well as the renamed operator.

Anyone know if this this a compiler bug or a correct interpretation 
of the Ada95 LRM??  If it is the latter then it seems to rule Ada95 
out for systems that need to provide protected fixed point maths.




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~1998-05-23  0:00 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-19  0:00 Renaming Fixed Point Mutiplicative operator in Ada 95 Stuart Hutchesson
1998-05-19  0:00 ` Matthew Heaney
1998-05-20  0:00   ` Robert Dewar
     [not found]     ` <matthew_heaney-ya023680002005981908570001@news.ni.net>
1998-05-21  0:00       ` John McCabe
1998-05-21  0:00         ` Robert Dewar
1998-05-21  0:00         ` Matthew Heaney
     [not found]       ` <01bd84c3$47215d60$440029a1@m00rq900>
1998-05-21  0:00         ` Robert Dewar
1998-05-21  0:00           ` Simon Pilgrim
1998-05-21  0:00             ` Matthew Heaney
1998-05-22  0:00               ` Robert I. Eachus
1998-05-22  0:00           ` Stuart Hutchesson
1998-05-22  0:00             ` Matthew Heaney
1998-05-23  0:00             ` Robert Dewar
1998-05-22  0:00           ` Rod Chapman
1998-05-22  0:00             ` John McCabe
1998-05-21  0:00         ` Robert Dewar
1998-05-21  0:00         ` Matthew Heaney
1998-05-21  0:00       ` Robert Dewar
1998-05-22  0:00         ` Robert I. Eachus
1998-05-23  0:00           ` Robert Dewar

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