comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: overriding "*", was Re: What's the ICFP Programming contest?
Date: Thu, 03 Jul 2003 07:55:45 GMT
Date: 2003-07-03T07:55:45+00:00	[thread overview]
Message-ID: <3F03E17E.7030305@attbi.com> (raw)
In-Reply-To: mq9Ma.675$C36.1204@rwcrnsc51.ops.asp.att.net

tmoran@acm.org wrote:
> For the contest I needed to override normal fixed point multiply and
> divide, so I declared
>   type Root_Numbers is delta ...
>   type Numbers is new Root_Numbers;
>   function "*"(Left, Right : Numbers) return Numbers;
>   A, B, C : Numbers;
> and tried to use it in formulas like
>   C := Numbers(A * B);
> But a compiler said the "*" was ambiguous between my function and Standard.
> It seems to me I overrode, and thus hid, Standard."*", no?
>   p.s. I did manage to write a program that successfully drove the first 5
> out of 9 race tracks.  It gets really lost though in the maze-like ones.
> The "programming" contest really becomes an "algorithm" contest there.

There are fixed-point multiplying operators that return universal-fixed. 
  You can't override or hide them.  What you can do is write:

    C := Numbers'(A * B);

This requires the result to be of type Numbers.  The magic is that in 
Ada 95, there can be an implict conversion on the assignment, but the 
qualified expression comes first.
-- 

                                                        Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  parent reply	other threads:[~2003-07-03  7:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-26  1:30 What's the ICFP Programming contest? tmoran
2003-06-26  8:24 ` Preben Randhol
2003-06-27 20:37   ` Michael Erdmann
2003-06-28  0:21     ` tmoran
2003-06-28  7:33       ` Michael Erdmann
2003-06-29  6:47         ` Hyman Rosen
2003-06-29 22:37           ` tmoran
2003-07-01  5:58             ` overriding "*", was " tmoran
2003-07-01 20:52               ` Randy Brukardt
2003-07-02 17:10                 ` tmoran
2003-07-02 18:13                   ` Randy Brukardt
2003-07-03  7:55               ` Robert I. Eachus [this message]
2003-07-04  7:01                 ` Robert I. Eachus
replies disabled

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