comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Fixed point multiplication ambiguity
Date: 1999/01/29
Date: 1999-01-29T00:00:00+00:00	[thread overview]
Message-ID: <F6BzAA.KKI.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 78sojm$crk$1@plug.news.pipex.net

Nick Roberts (Nick.Roberts@dial.pipex.com) wrote:

: ...
: What this means is that a compiler _deeply searches_ a complete context for
: a single, unambiguous, interpretation: in this case, the one with all
: Durations. I was simply assuming that Ada wouldn't be designed this way (I
: wouldn't have :-).

It doesn't actually need to search that far.  For example, in a
case like this, it is only concerned with directly visible
operators, and that is a pretty well-defined set.  The thing
which makes it a bit more complicated in many Ada compilers is
that all the predefined operators are not really inserted into the symbol
table, but instead "spring" into existence when referenced.

The one place where things can get truly exponential is in the
following:

    (a,b) & (c,d) & (e,f) & (g,h) & ...

The compiler is not "allowed" to look inside the aggregates until
it has determined what composite type each must be, by using context.
Because there are 4 predefined "&" operators for every array type,
and in the case of an array-of-composite, you could legitimately
use all 4 different operators in a single expression like the above,
some sort of tree-pruning is necessary.

As a little anecdote here, we had one user who rather than simply writing
a large aggregate as:

    (a,b,c,d,
     e,f,g,h,
     i,j,k,l, ... [for several pages]

They instead chose to write it as:

    (a,b,c,d) &
    (e,f,g,h) &
    (i,j,k,l) & ... [for several pages]

It blew out several gourds...

In all other cases, a "straightforward" (yeah, right) bottom-up
enumeration of all possibilities, with removal of illegal combinations 
on the way up, is generally efficient enough.

: Why? Because it means that the search space could, theoretically, end up
: getting rather big. But, of course, in practice, it's very unlikely to get
: _too_ big (especially considering the big search spaces modern compilers
: cover in the name of optimisation). It also means that sometimes an
: interpretation will be 'non-obvious' to someone reading the code. But that's
: the way it is. Maybe a change needed for Ada 200X?

I could see some change in the handling of fixed-point multiplication
in Ada 200X.  It has been a source of incompatibilities and surprises.
Other than that, though, any significant change to the overload
resolution rules is *extremely* unlikely in my view.

: Okay, I'm a cheeky so-and-so (you may have noticed), so my next question is:
: do you recommend I try developing 'tree pruning' techniques to cut down the
: search space (searching for interpretations), or just search it all 'brute
: force'?

Are you building an Ada compiler?  If so, I would suggest investing
in head examination techniques ;-).

: Again, thanks.

: -------------------------------------------
: Nick Roberts
: -------------------------------------------

-Tuck

--
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~1999-01-29  0:00 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-14  0:00 Fixed point multiplication ambiguity Marc A. Criley
1999-01-14  0:00 ` Tom Moran
1999-01-14  0:00 ` Tucker Taft
1999-01-15  0:00   ` robert_dewar
1999-01-28  0:00   ` Nick Roberts
1999-01-28  0:00     ` Tucker Taft
1999-01-28  0:00       ` robert_dewar
1999-01-29  0:00       ` Nick Roberts
1999-01-29  0:00         ` Tucker Taft
1999-01-29  0:00           ` Nick Roberts
1999-01-29  0:00             ` Tucker Taft [this message]
1999-02-01  0:00               ` Robert I. Eachus
1999-02-02  0:00               ` Building a compiler (was: Fixed point multiplication ambiguity) Nick Roberts
1999-02-03  0:00                 ` dennison
1999-02-03  0:00                 ` Chris Morgan
1999-02-04  0:00                   ` robert_dewar
1999-02-04  0:00                     ` Garbage collection - was " news.oxy.com
1999-02-04  0:00                       ` robert_dewar
1999-02-05  0:00                         ` David Botton
1999-02-05  0:00                         ` Tom Moran
1999-02-18  0:00                         ` news.oxy.com
1999-02-18  0:00                           ` Garbage collection - was Re: Building a compiler Samuel Mize
1999-02-19  0:00                             ` Samuel Mize
1999-02-18  0:00                           ` Garbage collection - was Re: Building a compiler (was: Fixed point multiplication ambiguity) AdaHag
1999-02-18  0:00                           ` dewar
1999-02-18  0:00                           ` David Botton
1999-02-19  0:00                           ` Steven Hovater
1999-02-20  0:00                           ` A Modest Defense of ACT (though they are big boys and can take care of themselves) Steve Quinlan
1999-02-21  0:00                             ` dewar
1999-02-22  0:00                               ` Matthew Heaney
1999-02-21  0:00                                 ` bill
1999-02-22  0:00                                   ` Larry Kilgallen
1999-02-22  0:00                                 ` dennison
1999-02-22  0:00                             ` dennison
1999-02-24  0:00                               ` Steve Quinlan
1999-02-25  0:00                                 ` dennison
1999-02-26  0:00                                   ` Steve Quinlan
1999-02-26  0:00                                     ` dennison
1999-02-27  0:00                                       ` Simon Wright
1999-02-27  0:00                                         ` Dave Taylor
1999-02-28  0:00                                       ` dewar
1999-02-25  0:00                                 ` dewar
1999-02-25  0:00                                   ` Steve Quinlan
1999-02-25  0:00                                     ` robert_dewar
1999-02-05  0:00                     ` GC+HC for GNAT/GCC (was: Building a compiler) Nick Roberts
     [not found]                       ` <m33e4jvs1n.fsf@muc.de>
1999-02-06  0:00                         ` GC+FSD for GNAT/GCC Nick Roberts
1999-02-07  0:00                           ` robert_dewar
1999-02-05  0:00                   ` Building a compiler Nick Roberts
1999-02-05  0:00                     ` Tucker Taft
1999-02-06  0:00                       ` Nick Roberts
1999-01-30  0:00             ` Fixed point multiplication ambiguity robert_dewar
1999-02-02  0:00               ` Building a compiler (was: Fixed point multiplication ambiguity) Nick Roberts
1999-02-03  0:00                 ` robert_dewar
1999-02-03  0:00                 ` Tucker Taft
1999-01-28  0:00     ` Fixed point multiplication ambiguity robert_dewar
1999-01-14  0:00 ` Matthew Heaney
1999-01-14  0:00 ` David C. Hoos, Sr.
1999-01-14  0:00 ` bob
1999-01-14  0:00 ` 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