PHILBRCK@MAINE.BITNET (07/20/90)
In the NEWS section (page 14) of my July 1990 issue of "SUNEXPERT", there was an announcement entitled "C++ Gets Typecast". In a nutshell, it states that C++ will soon have parameterized types. The article further states that AT&T is buying the technology from Object Design Inc., Cambridge, MA. Does anybody have ODI's full address, or the name(s) and phone number(s) of their contact person(s)? I apologize if this in NOT the correct place to post; I'm new in the neighborhood. If anyone is interested, my (just decided) thesis topic currently goes by the name, "Software Reuse Issues in the X Window System". I'll be looking quite closely at how language mechanisms effect toolkit implementation (C, C++, and Ada languages), thus my interest in the the "new" C++. Thanks for reading this far, and any help is enormously appreciated! REcursive thanks, Long before the flag burning issue: Steve Philbrick "The right to do something does 237 Neville Hall not mean that doing it is right." University of Maine -- William Safire Orono, ME 04469 philbrck@maine.bitnet
jlol@ALTAR.EE.BYU.EDU (Jay Lawlor) (07/23/90)
In the NEWS section (page 14) of my July 1990 issue of "SUNEXPERT", there was an announcement entitled "C++ Gets Typecast". In a nutshell, it states that C++ will soon have parameterized types. Since someone brought up the subject, I have a question. I read the section on parameterized types in the "Selected Readings" manual (don't have it on me right now for exact page or anything) that came with AT&T Cfront 2.0. I was disappointed when I came to the sentence about how C++ didn't support it but it could be faked with macros (I believe the Stroustrup book gives an example.) So my question is, is there something difficult about implementing it (I'm not a compiler expert) or was it just a whizzy feature that wasn't deemed useful enough to clutter the language with until now? I understand the necessity of making sure the member functions used in the parameterized type exist for each class that might use it. What other difficulties are there, and, is it worth it given that it could be done using macros? Jay jlol@ee.byu.edu
stenger@csc.ti.com (Dan Stenger) (08/08/90)
To encourage additional experimentation with parameterized types in the C++
programming community we have made available an implementation of "templates"
as described by Stroustrup in his 1988 USENIX C++ Conference paper
"Parameterized types for C++". Here is a simple example of this syntax:
template<class T> class Vector<T> {
T* v;
int sz;
public:
Vector<T>(int);
T& operator[](int);
inline T& elem(int i) { return v[i]; }
};
template<class T>
T& Vector<T>::operator[](int i) {
if (i<0 || sz<=i) error("vector: range error");
return elem(i);
};
template<class T>
Vector<T>::Vector<T>(size) {
v = new(T[size]);
};
DECLARE Vector<char*>; // create definitions for a vector of strings
IMPLEMENT Vector<char*>; // generate code to support vector of strings
Vector<char*> vs(30); // declare a vector of 30 strings
This implementation is provided through an enhanced macro facility in a
portable C++ preprocessor. We started with the DECUS C preprocessor that is
provided in the MIT X Consortium distribution. First, we made it compliant
with ANSI C (except for tri-graphs). Next, we made it recognize a #pragma
form with the syntax "#pragma defmacro NAME PROGRAM", where NAME is the macro
keyword to use in the source text and PROGRAM is a program to execute to
translate the macro. Finally, we wrote the defmacros to translate the
template syntax to standard C++.
Interested parties can find all of this available for anonymous ftp from:
csc.ti.com (internet address 128.247.159.141)
in compressed form in the file:
/pub/cpp.tar.Z
Be forewarned that this is experimental, research software (although we have
used it extensively here at TI) and the standard syntax for parameterized
types is still evolving (the current ANSI proposal is slightly different).
Also, I am willing to help and answer questions but I only have a limited
capacity to deal with them.
Dan Stenger
Texas Instruments
Computer Science Center
stenger@csc.ti.com