From owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org  Thu Sep 28 21:07:09 2017
Return-Path: <owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom8
Delivered-To: sc22wg5-dom8@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 20D77358929; Thu, 28 Sep 2017 21:07:08 +0200 (CEST)
Delivered-To: sc22wg5@open-std.org
X-Greylist: delayed 582 seconds by postgrey-1.34 at www5.open-std.org; Thu, 28 Sep 2017 21:07:08 CEST
Received: from math.jpl.nasa.gov (unknown [137.79.7.57])
	by www.open-std.org (Postfix) with ESMTP id 507C73585C0
	for <sc22wg5@open-std.org>; Thu, 28 Sep 2017 21:07:07 +0200 (CEST)
Received: by math.jpl.nasa.gov (Postfix, from userid 3593)
	id C2B5C33DA7C; Thu, 28 Sep 2017 11:57:22 -0700 (PDT)
Subject: Re: (j3.2006) (SC22WG5.5979) Generic programming examples
From: Van Snyder <van.snyder@jpl.nasa.gov>
To: sc22wg5 <sc22wg5@open-std.org>
In-Reply-To: <etPan.59cd3343.3eb1add9.1302@sourceryinstitute.org>
References: <20170927201113.6D137358742@www.open-std.org>
	 <CEB03336-C898-4C72-9BB9-C533DBDFC4C8@cray.com>
	 <20170928020816.B2E4D358742@www.open-std.org>
	 <20170928123430.2C442358929@www.open-std.org>
	 <20170928161910.0439E358A27@www.open-std.org>
	 <etPan.59cd3343.3eb1add9.1302@sourceryinstitute.org>
Content-Type: multipart/alternative; boundary="=-v47M449hhpk4nRSFjytj"
Date: Thu, 28 Sep 2017 11:57:22 -0700
Message-ID: <1506625042.32527.321.camel@math.jpl.nasa.gov>
Mime-Version: 1.0
X-Mailer: Evolution 2.32.3 (2.32.3-37.el6) 
Sender: owner-sc22wg5@open-std.org
Precedence: bulk


--=-v47M449hhpk4nRSFjytj
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, 2017-09-28 at 10:37 -0700, Damian Rouson wrote:
>=20
>=20
>=20
>=20
> On September 28, 2017 at 9:19:14 AM, Bill Long (longb@cray.com) wrote:
>=20
>=20
> >=20
> >=20
> > > On Sep 28, 2017, at 7:34 AM, Clune, Thomas L. (GSFC-6101)
> > <thomas.l.clune@nasa.gov> wrote:=20
> > >=20
> > > Sorry - not sure how my subconscious injected the word
> > =E2=80=9Cexceptions=E2=80=9D below. I meant =E2=80=9CUsing generics/tem=
plates should not
> > make us lose this other [type-bound procedures] capability.=E2=80=9D=
=20
> > >=20
> >=20
> > Makes more sense now.=20
> >=20
> > A type bound procedure referenced though a polymorphic variable
> > cannot itself be a template because the compiler does not know what
> > procedure is being called at compile time. However, inside the
> > specific TBP, you can call worker routines that do the actual work,
> > and those can be written as templates if that would be useful. There
> > is a (probably small) performance hit for the second call, but you
> > are already making an anti-performance decision by using the TBP
> > path in the first place. Whether this matters that much depends on
> > how you decide to organize the code.=20
>=20
> I suspect that these are some of the reasons that many in the C++
> community are moving away from runtime polymorphism and inheritance
> and migrating more toward compile-time polymorphism and templates.
> Partly for this reason, I=E2=80=99ve been hoping to get one collaborator =
to
> join J3/WG5 who specializes in language design, has some experience on
> the C++ committee, has an interest in modern Fortran, and was one of
> the first people to mention the aforementioned trend in C++
> programming practices.  What Bill describes above might be a good
> compromise between the two programming styles. I=E2=80=99m not surprised
> there=E2=80=99s some tension between the two.


As far as I know, Ada didn't have the same kinds of growing pains with
generic packages that C++ had with templates, or the same problems with
the relationship of polymorphism to generic packages that C++ had
between polymorphism and templates.  Should we really be trying to copy
a C++ kludge when we have an Ada example that worked just fine right out
of the box?


--=-v47M449hhpk4nRSFjytj
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; CHARSET=3DUTF-8">
  <META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.32.2">
</HEAD>
<BODY>
On Thu, 2017-09-28 at 10:37 -0700, Damian Rouson wrote:
<BLOCKQUOTE TYPE=3DCITE>
    <BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=3DCITE>
    <BR>
    On September 28, 2017 at 9:19:14 AM, Bill Long (<A HREF=3D"mailto:longb=
@cray.com">longb@cray.com</A>) wrote:<BR>
    <BR>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=3DCITE>
    <BLOCKQUOTE TYPE=3DCITE>
        <BR>
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=3DCITE>
    <BLOCKQUOTE TYPE=3DCITE>
        <BR>
        &gt; On Sep 28, 2017, at 7:34 AM, Clune, Thomas L. (GSFC-6101) &lt;=
thomas.l.clune@nasa.gov&gt; wrote:&nbsp;<BR>
        &gt;&nbsp;<BR>
        &gt; Sorry - not sure how my subconscious injected the word &#8220;=
exceptions&#8221; below. I meant &#8220;Using generics/templates should not=
 make us lose this other [type-bound procedures] capability.&#8221;&nbsp;<B=
R>
        &gt;&nbsp;<BR>
        <BR>
        Makes more sense now.&nbsp;<BR>
        <BR>
        A type bound procedure referenced though a polymorphic variable can=
not itself be a template because the compiler does not know what procedure =
is being called at compile time. However, inside the specific TBP, you can =
call worker routines that do the actual work, and those can be written as t=
emplates if that would be useful. There is a (probably small) performance h=
it for the second call, but you are already making an anti-performance deci=
sion by using the TBP path in the first place. Whether this matters that mu=
ch depends on how you decide to organize the code.&nbsp;
    </BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=3DCITE>
    I suspect that these are some of the reasons that many in the C++ commu=
nity are moving away from runtime polymorphism and inheritance and migratin=
g more toward compile-time polymorphism and templates.&nbsp; Partly for thi=
s reason, I&#8217;ve been hoping to get one collaborator to join J3/WG5 who=
 specializes in language design, has some experience on the C++ committee, =
has an interest in modern Fortran, and was one of the first people to menti=
on the aforementioned trend in C++ programming practices.&nbsp; What Bill d=
escribes above might be a good compromise between the two programming style=
s. I&#8217;m not surprised there&#8217;s some tension between the two.<BR>
</BLOCKQUOTE>
<BR>
As far as I know, Ada didn't have the same kinds of growing pains with gene=
ric packages that C++ had with templates, or the same problems with the rel=
ationship of polymorphism to generic packages that C++ had between polymorp=
hism and templates.&nbsp; Should we really be trying to copy a C++ kludge w=
hen we have an Ada example that worked just fine right out of the box?<BR>
<BR>
</BODY>
</HTML>

--=-v47M449hhpk4nRSFjytj--
