This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

language-independent types (was: RFC: attribute "unpadded")


On 25-Aug-2002, Zack Weinberg <zack@codesourcery.com> wrote:
> On Mon, Aug 26, 2002 at 12:03:38PM +1000, Fergus Henderson wrote:
> > On 23-Aug-2002, Zack Weinberg <zack@codesourcery.com> wrote:
> > > 
> > > (Idle thought: Is our language-independent type system powerful enough
> > > that we could implement ML type inference with it?  I suspect not.)
> > 
> > The Mercury front-end supports type inference in a manner very similar
> > to ML, and maps this to GCC's C-like type system.  The mapping is pretty
> > straight-forward, actually: polymorphically typed variables are given
> > the GCC type represented by `ptr_type_node', i.e. `void *'.
> 
> I guessed as much, but I meant something different: could we implement
> a type inference engine as a language-independent component,

I doubt this would be worthwhile, since different languages -- and
sometimes even different implementations of the "same" language --
often use different algorithms for type inference.  The amount of code
which could be reused by providing a language-independent "engine"
for doing type inference would be very small.  Furthermore, this
code is very tightly coupled with the details of the language
and the front-end's data representations.  The portion of a type
inference algorithm which is language-independent is really a very
small portion, and the benefits of code reuse in this case would be
outweighed by the drawbacks of increased coupling.

So I think it is better to leave it up to the front-end to handle type
inference.  However, Something that I do think would be worthwhile,
in the long run, is providing support for polymorphic types, e.g.
something along the lines of the type system in ILX
(see <http://research.microsoft.com/~dsyme/netproj.htm>).

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]