From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Ada to C++ Translators
Date: 1998/02/23
Date: 1998-02-23T00:00:00+00:00 [thread overview]
Message-ID: <6cs8ml$188@netlab.cs.rpi.edu> (raw)
In-Reply-To: 6cn8lg$cao@netlab.cs.rpi.edu
On 21 Feb 1998, Esa Pulkkinen wrote:
> [Sorry this is a bit off-topic for comp.lang.ada, so I'll crosspost
and
> put followups to comp.lang.c++.moderated.]
I think it is perfectly appropriate for comp.lang.ada, as long as
language
warriors restrain themselves.
> Brian Rogoff <bpr@shell5.ba.best.com> writes at comp.lang.ada:
> > I'd be interested in hearing how a well designed Ada program that
makes
> > use of constrained genericity gets translated to a well designed C++
> > program. I haven't been following the C++ standard for a while, but
I
> > thought that there was no constrained genericity in C++, and that
the
> > work-arounds would not really be considered "well-designed".
>
> See http://www.cs.tut.fi/~esap/instructive/ for one method for
> converting a program which uses constrained genericity to C++ using
> class template partial specialization. It uses class template partial
> specialization to implement different versions of the class for the
case
> where the class is derived from another class, and for the case where
it
> isn't. I think it's as well-designed as it ever will without explicit
> language support, but I'd like to hear your opinions.
Very interesting; the workaround I am familiar with is the one where you
do an assignment to the constraint type in some method. I'll certainly
try your method out next time I have a capable C++ compiler. Still, I
have
some issues, namely
(1) What if the generic parameters being constrained are not
tagged types/classes? In the case of Ada, there are generic
constraints to match all of the types in the language. This is
not such a big deal in C++, since you don't have ranges, but it
surely does make such a translation harder.
(2) Function and procedure parameters. I assume you'd just wrap these up
in classes, right? That's a bit tedious.
(3) Formal package parameters. This is my favorite "gee-whiz" feature of
Ada 95. It's related to (1) and (2) in that I can (and do!) bundle
up non-tagged generic abstractions (like Stacks and Dictionaries
say)
and then use instantiations of both with their actual parameters
constrained to be the same. Once again, it seems with your
translation
I have to first make everything a class.
That said, I think your translation is a very neat trick. In a "feature
restrained" program, done in a very stylized way, it would work, but I
fear that a straightforward and idiomatic Ada 95 program would not
translate to a similarly straightforward (Draft) ISO C++ program.
Almost all of my Ada code uses constrained genericity somewhere.
-- Brian
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
next prev parent reply other threads:[~1998-02-23 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-02-13 0:00 Ada to C++ Translators David Kusuda
1998-02-14 0:00 ` Larry Kilgallen
1998-02-16 0:00 ` David Weller
1998-02-18 0:00 ` Jean D. Ichbiah
1998-02-18 0:00 ` David Weller
1998-02-18 0:00 ` Brian Rogoff
1998-02-21 0:00 ` Esa Pulkkinen
1998-02-23 0:00 ` Brian Rogoff [this message]
1998-02-19 0:00 ` Jean D. Ichbiah
1998-02-19 0:00 ` Larry Kilgallen
1998-02-25 0:00 ` Scott Leschke
1998-02-25 0:00 ` David Weller
1998-02-19 0:00 ` Delphi & Ada; Ada to C++ Nick Roberts
1998-02-19 0:00 ` David Weller
1998-02-19 0:00 ` Nick Roberts
1998-02-19 0:00 ` Jon S Anthony
1998-02-20 0:00 ` Nick Roberts
1998-02-21 0:00 ` Richard Kenner
1998-02-21 0:00 ` Robert Dewar
1998-02-21 0:00 ` Simon Wright
1998-02-21 0:00 ` Richard Kenner
1998-03-05 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox