comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Shared Generic Instance Code
Date: 1997/04/03
Date: 1997-04-03T00:00:00+00:00	[thread overview]
Message-ID: <dewar.860114590@merv> (raw)
In-Reply-To: sO6r4AADiBRzEwoj@marnhull.demon.co.uk


iBill Keen said

<<But surely the mechanism for shared code is already there because of
dynamic instantiations like this.

with text_io;
procedure p (x : integer) is
  subtype T is integer range 0..x;
  package Tio is new text_io.integer_io(T);
begin
  Tio.put(0);
end;

It cannot add complexity if it alredy exists.>>

Robert replies:

Sorry, I don't get the point. Yes, GNAT can handle this case. No, there
is no special complexity in handling this case (note that the base type
of T, which is what of course is significant, is always Integer).

Shared code would add a LOT of complexity. Consider for example a generic
formal type "digits <>". Now this code must handle all possible lengths
of floating-point. 

This is easy if you have only one length (that's what the Rational compiler
used to do), or if you do everything in the longest type, and don't worry
too much that you are cheating on operatoins like Unchecked_Conversion
(that's what RR used to do),

but to do it right with multiple fpt precisions, and not introduce a big
efficiency penalty -- that's hard, and close to impossible, respectively!

Obviously any Ada compiler would be happy to share certain instantiations.
For examle, if we instantiate Integer_IO three times all for type Integer,
tha's probably pretty easy to share! However, even the mechanism to sometimes
share in the simple cases introduces a lot of complexity. In fact as Bob
pointed out, the sometimes share solution is probably harder than either
of the "pure" solutions.





  reply	other threads:[~1997-04-03  0:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-01  0:00 Shared Generic Instance Code david scott gibson
1997-04-01  0:00 ` Joel VanLaven
1997-04-01  0:00   ` Robert A Duff
1997-04-02  0:00     ` Robert Dewar
1997-04-02  0:00       ` Robert A Duff
1997-04-02  0:00   ` Robert Dewar
1997-04-02  0:00     ` Robert A Duff
1997-04-01  0:00 ` Pat Rogers
1997-04-01  0:00 ` Robert A Duff
1997-04-02  0:00   ` Robert Dewar
1997-04-05  0:00   ` Nick Roberts
1997-04-05  0:00     ` Robert A Duff
1997-04-05  0:00       ` Nick Roberts
1997-04-06  0:00       ` Robert Dewar
1997-04-02  0:00 ` Jon S Anthony
1997-04-02  0:00   ` Robert A Duff
1997-04-03  0:00   ` Robert Dewar
1997-04-03  0:00 ` Jon S Anthony
1997-04-03  0:00   ` Robert Dewar
1997-04-03  0:00 ` Corey Minyard
1997-04-03  0:00 ` Bill Keen
1997-04-03  0:00   ` Robert Dewar [this message]
1997-04-04  0:00     ` Fergus Henderson
1997-04-04  0:00       ` Robert Dewar
1997-04-04  0:00   ` Robert A Duff
1997-04-04  0:00 ` Bill Keen
1997-04-04  0:00   ` Robert Dewar
1997-04-05  0:00     ` Tom Moran
1997-04-06  0:00       ` Nick Roberts
1997-04-07  0:00       ` Robert Dewar
replies disabled

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