comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Shared Generic Instance Code
Date: 1997/04/04
Date: 1997-04-04T00:00:00+00:00	[thread overview]
Message-ID: <E83Bwt.Dpz@world.std.com> (raw)
In-Reply-To: sO6r4AADiBRzEwoj@marnhull.demon.co.uk


In article <sO6r4AADiBRzEwoj@marnhull.demon.co.uk>,
Bill Keen  <billy@marnhull.demon.co.uk> wrote:
>In article <dewar.859987468@merv>, Robert Dewar <dewar@merv.cs.nyu.edu>
>writes
>> On the other hand, shared generics add a lot
>>of complexity to a compiler. 
>
>He also says Gnat does not share code between generic instances.
>
>But surely the mechanism for shared code is already there because of
>dynamic instantiations like this.

No, it's not *nearly* that simple.  Yes, your example is sharing code
between multiple (run-time) instances, but they're all essentially the
same.  That is, a macro-expanding implementation works just fine in this
example (and yes, the expanded "macro" machine code might get invoked
many times), and still generate just one copy of the code.

Consider, for example: can you share code for "is new
Text_IO.Integer_IO(Integer)" and "is new
Text_IO.Integer_IO(Super_Long_Integer)", where Super_Long_Integer is
range 0..2**1000, which might be accepted by some (mythical,
unfortunately) implementation.

>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.

Sorry, but shared-code generics are far more complex than you imply
here.

- Bob




  parent reply	other threads:[~1997-04-04  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 ` Pat Rogers
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 ` 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 ` Corey Minyard
1997-04-03  0:00 ` Bill Keen
1997-04-03  0:00   ` Robert Dewar
1997-04-04  0:00     ` Fergus Henderson
1997-04-04  0:00       ` Robert Dewar
1997-04-04  0:00   ` Robert A Duff [this message]
1997-04-03  0:00 ` Jon S Anthony
1997-04-03  0:00   ` Robert Dewar
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