J. David Bryan wrote:
On Saturday, July 31, 2010 at 6:01, Frank Heckenbach wrote:
For the 3 big things I mentioned, I know C++ has them already. I don't know if Ada does, perhaps you can give us some information here, e.g., is its object model comparable to those GPC supports or that of C++;
I am not familiar with objects in GPC, and only tangentially familiar with C++ (i.e., have not done any serious programming in it). However, the short answer is yes; objects are called "tagged types" in Ada.
There is a guide that discusses comparable Ada and C++ features here:
http://www.adahome.com/Ammo/Cplpl2Ada.html
or more nicely formatted here:
http://home.agh.edu.pl/~jpi/download/ada/guide-c2ada.pdf
It has a section devoted to the Ada object model:
http://www.adahome.com/Ammo/Cplpl2Ada.html#3
(Note that this guide discusses Ada 95, which superceded the original Ada 83, and has itself been superceded by Ada 2005. As such, it is a bit out of date, although language revisions have been kept backward-compatible. Ada undergoes periodic improvements; the next language revision is scheduled for 2012.)
does Ada supported exception handling and how;
Yes; see:
http://www.adahome.com/Ammo/Cplpl2Ada.html#1.2.7
does it support something like templates (IOW, how can one implement, say, a generic list, applicable to any given type, with strong type-checking).
Yes; templates are called "generics" in Ada. See:
OK, looks quite good actually. (Though their example and comparison WRT exceptions is misleading -- they emulate Ada's name-based selection in C++ and complain that's it less "safe" (???), whereas the common thing to do in C++ is type-based selection (which I prefer, since it allows you to add extra information to exceptions in the form of data fields), which is just as safe, and apparently not available in Ada, though it probably can be emulated somehow.)
Also, I notice that Ada is quite a bit more verbose. While I'm no fan on "line noise like" languages such as Perl, I also dislike excessive verbosity (which I roughly define as the amount of tokens that add no new information -- either because they repeat previous information, or they're just syntactically required for the sake of it, a Pascal example would be "to begin do", 3 keywords for a single thing). Also Ada requires explicit instantiation of generics, while C++ instantiates templates automatically, etc. Of course, for a converter target these is no major issues.
Indeed, any language may be used as the intermediate for GPC. However, I would expect that the effort required to write a translator would vary, depending on the closeness of the mapping between GPC and that language. My impression is that C++ doesn't map particularly well to Pascal's type structure (subranges, sets, packed structures), and while that may be overcome with moderate effort, as you say, that effort may be less with a different choice of intermediate language. Granted, though, that this mapping is just one of several variables influencing that choice.
That's the point. I think in the big picture, it just doesn't matter much (especially given that most of the support could be written on the C++ level, probably even on the Pascal level later, without performance loss due to inlining, and doesn't have to be built into the compiler as it's now).
But while reading the above links, I also noticed that Ada is very strict about types etc. (no surprise given its main fields of use). While Pascal itself is so, too, GPC actually has to support some dialect and extensions that are not. As I wrote elsewhere, it basically covers everything that's in C WRT low-level features. Though you may consider this dirty, the fact is that a converter which is to be compatible to the existing GPC must support them. Is this possibke in Ada?
Frank