comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: Re: User-defined type attributes (replacing genericity)
Date: Fri, 14 Mar 2008 10:51:25 -0700 (PDT)
Date: 2008-03-14T10:51:25-07:00	[thread overview]
Message-ID: <821256cd-2d20-46dd-92d2-cdd21181dbb8@s8g2000prg.googlegroups.com> (raw)
In-Reply-To: k4zvct2zqh5t.10e4n7n078983.dlg@40tude.net

On Fri, 14 Mar 2008 15:31:40 +0100, Georg Bauhaus wrote:
> Without generics, there is only one Is_Highest, as might be
> expected.

On Mar 14, 8:48 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> Why there have to be two? The whole idea of generics was to have *one*
> generic body. This is why it is called generic [programming].

Here's the nut of the problem.  There is one generic body in the code
of the programming language.  When you substitute type parameters into
that generic body, you get multiple different manifestations of that
original generic body, that is, multiple bodies, one for each type.
And that means multiple versions as translated into machine code.
This is indeed the primary desideratum of generic programming.  Having
said this, there's a standard technique of converting type operations
into virtual function calls.  I feel like I need to say this--these
aren't the same thing.  This allows the reduction of the manifestation
a generic body to a single canonical form.  This has a single version
in machine code.

A realistic system for generic programming should support both modes
of code generation.  This allows the developer to determine their own
answer to the code-size vs. performance trade-off.  Ada has already
taken the stance, as evidenced by representation clauses, that it will
support both high and low levels of abstraction.  Eliminating generics
would force everything into virtual function calls, choose code-size
over performance, and make that choice on behalf of every programmer.

If you go down the road of requiring all method calls to be virtual,
of requiring that there be run-time manifestations of all meta-
language features, you get Java.  Java has its place.  So does Ada.
These aren't the same place.

Eric





  reply	other threads:[~2008-03-14 17:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 18:58 User-defined type attributes Eric Hughes
2008-03-12 21:23 ` Dmitry A. Kazakov
2008-03-13 18:32   ` Eric Hughes
2008-03-13 19:58     ` Dmitry A. Kazakov
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  9:00         ` Dmitry A. Kazakov
2008-03-14 14:36           ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-15  3:04           ` User-defined type attributes Randy Brukardt
2008-03-15  9:33             ` Dmitry A. Kazakov
2008-03-14 14:31         ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-14 14:48           ` Dmitry A. Kazakov
2008-03-14 17:51             ` Eric Hughes [this message]
2008-03-14 18:58               ` Dmitry A. Kazakov
2008-03-14 20:19                 ` Eric Hughes
2008-03-15  4:01               ` Randy Brukardt
2008-03-14 16:58           ` Georg Bauhaus
2008-03-14 18:39             ` Dmitry A. Kazakov
2008-03-15  9:39               ` Dmitry A. Kazakov
2008-03-14  1:46       ` User-defined type attributes Randy Brukardt
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  3:55       ` Eric Hughes
2008-03-14  9:01         ` Dmitry A. Kazakov
2008-03-14 18:04           ` Eric Hughes
2008-03-14  1:46 ` Randy Brukardt
2008-03-14  4:41   ` Eric Hughes
2008-03-15  3:20     ` Randy Brukardt
2008-03-17  4:38       ` Eric Hughes
2008-03-17 21:03         ` Randy Brukardt
2008-03-17 21:58           ` Eric Hughes
replies disabled

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