From: jac@moonshine.llnl.gov (James A. Crotinger)
Newsgroups: comp.sys.amiga.programmer
Subject: Amiga C++ class libraries (was Re: Comeau C++ class libraries)
Date: 29 Sep 92 05:26:06 GMT
Organization: Magnetic Fusion Energy - LLNL

jmrg9881@uxa.cso.uiuc.edu (Jon Reid) writes:
> What sorts of "pre-rolled" classes are included with the Comeau C++
> package?  Is it mostly the standard container classes?  Are there any
> Amiga GUI-specific classes?

  Currently Comeau C++ only includes the various iostream classes
(iostreams, fstreams, strstreams). (Greg had told me once that complex
would be included, but I see that it isn't there---Greg???)

  Although there are no standard container classes, or other non-GUI
stuff, these things tend to be pretty portable (if written for
CFRONT)---I have a library of such things which was written at work,
and the port to the Amiga was trivial. Most of our class library is
proprietary (although we are going to try to get it released by the
lab's Tech Transfer [NOT!] office). However, the string class which we
use is one we got off the net. I've posted a port of it on BIX, and if
there is interest I could make it available for anonymous FTP (it's
rather large, so I don't think I'll post it).

  There are no Amiga specific classes with Comeau. I was working on
some of these earlier this year, but lately have been too short on
time. I have a fairly complete set of classes for exec, and a start
on Intuition (but have done little testing).

  One problem with designing an Amiga class library is trying to
decide which paradigm to follow. You can try to emulate the Amiga
system structures (which are pretty "object oriented" in the first
place), or you can start from scratch and make something that is more
C++-like.

  The first technique, which is the approach I was taking for
starters, is fairly easy---you just duplicate the C header files,
making the inheritance explicit, making appropriate pieces of
structures private, adding inline accessor functions, and, where
appropriate, adding inline functions to encapsulate the calls to the
Amiga system routines. (This is similar to what Lattice did with their
ill-fated C++ product).  This approach has the benefit that it looks
similar to C programming, for which there is ample documentation and
examples, but is cleaner (because you're using C++). However, this
approach relies on the objects being bitwise the same as the
equivalent C data structure (since you want to be able to pass them
directly to the Amiga system routines). This, of course, means no
virtual functions, which in turn means no polymorphism (at least not
at this low level). The combination of public inheritance, dynamically
allocated memory (which many structures require---e.g. chip ram), and
no virtual destructors, is a recipe for trouble.

  The alternative is to write something from scratch, possibly still
maintaining the look-and-feel of the C structures and intuition, but
leaving the concerns about data layout to the implementation. You then
need to provide C++ wrappers for just about all of the system calls,
and you want to make all this as efficient as possible.

  The latter is what I ultimately want. However, I think I would like
to have the former---the C++-ized version of the C stuff---to use
in implementing the latter. 

  Jim
--
-------------------------------------------------/\--------------------------
James A. Crotinger     Lawrence Livermore N'Lab // \ The above views are mine
jac@moonshine.llnl.gov P.O. Box 808;  L-630 \\ //---\  and are not neces-
(510) 422-0259         Livermore CA  94550   \\/Amiga\  sarily those of LLNL.