HDTenEightyP/NetNews huggingface dataset:
From: rmartin@thor.Rational.COM (Bob Martin)
Subject: Re: "type safety" deemed essential
Organization: Rational
Date: Tue, 22 Dec 1992 17:41:54 GMT

roger@genie.UUCP (Roger H. Scott) writes:

|In article <rmartin.724430168@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
|>kocks@leland.Stanford.EDU (Peter Kocks) writes:
|>
|>>My $0.02.  Use Obj-C.  I have just spent a fair amount of time
|>>comparing strong vs weak type casting systems [...]
|>
|>For any significant industrial application, I think strong typing is
|>utterly essential.  It is just too easy to create horrible run time
|>errors without type safety.  

|This sounds like theory rather than practice speaking.  Let's hear from the
|(net) C++ user community: who has written a non-trivial commercial C++ 
|application *without* making significant use of either type casting [(T *)]
|or run-time type checking [Bar *bar_p = foo_p->asBar();]?  I maintain that
|C++ makes it *very* difficult to do without at least one or the other of these
|(Eiffel-style "anchored" virtual function return types would go a long way to
|alleviate this).  I'm hoping that templates will help in this regard, but they
|haven't been available long enough to judge.

There is no theory involved in the "horrible run time errors"
description above.  I have spent many years writing C code and
experiencing those errors.  There is also no theory involved in the
reduction in those errors caused by strong typing.  Believe me, I have
had plenty of, as you say, "practice".

Granted it is very difficult to create a large scale C++ application
without using some type casting.  There are a number of reasons for
this.  One of the most significant is contravariant return types.
However, the standards committee has accepted covariant return types
from virtual functions, so this source of typecasts will dissapear.

However, I am confused by your statement.  What does typecasting have
to do with the need for strong typing in industrial languages???

--
Robert Martin                        Training courses offered in:
R. C. M. Consulting                       Object Oriented Analysis
2080 Cranbrook Rd.                        Object Oriented Design
Green Oaks, Il 60048 (708) 918-1004       C++
Newsgroups: comp.lang.c++
From: bear@kestrel.fsl.noaa.gov (Bear Giles)
Subject: Weird problem under Sun/C++
Organization: Forecast Systems Labs, NOAA, Boulder, CO USA
Date: Wed, 30 Dec 1992 00:33:04 GMT

I wrote a simple relational database in C++, but a coworker is having a
truly bizarre problem using it:

  I can link my programs without problem.  (More precisely, I have been
  able to link without problems in the past).

  If she attempts to link a program using the same library (and compiler,
  linker, etc) the linker can't find one particular function.  

  If she extracts the object file containing this function and attempts
  to link it as a separate object the function is found (but since this
  module is in the middle of a call tree we still have problems).

The function in question takes five arguments; unfortunately two of those
arguments are functions taking 2 and 5 arguments respectively.  On top of
that I use "const unsigned char * const" extensively so the length of the
mangled function name is around 65 characters long, rather than the
apparent 4 characters ("find").

And of course, Sun technical support will be out until next week, leaving
us dead in the water.

Any ideas?


Bear Giles
bear@fsl.noaa.gov
Newsgroups: comp.lang.c++
From: reagle@umbc8.umbc.edu (Mr. Joseph Reagle; MEYERHOFF (U))
Subject: Do I need to worry about what the compiler will do?
Organization: University of Maryland, Baltimore County Campus
Date: Thu, 24 Dec 1992 15:55:26 GMT


	This is the program I spoke of earlier concerning linked lists, and 
constructors.  My question is since each node in the list is an object, is this
inefficient?  Is each function of each object repeated in the object or 
executable code?


// A simple generic linked lijst.
#include <iostream.h>

template <class data_t>
class list {
	data_t	data;
	list	*next;
puclic:
	list (data_t d);
	void add(list *node) {node->next = this; next = 0;}
	list *getnext() {return next;}
	data_t getdata () {return data;}
};

template <class data_t>
list<data_t>::list (data_t d)
{
	data = d;
	next = 0;
}

main ()
{
	list<char> start ('a');
	list<char> *p, *last;
	int i;

	// build a linked list
	last = &start;
	for (i=0; i <26, i++) {
		p = new list<char> ('a' + i );
		p->add(last);
		last = p;
	}

	// follow list
	p = &start;
	while (p) {
		cout << p->getdata();
		p = p->getnext();
	}

	return 0;
Newsgroups: comp.lang.c++
From: koelma@fwi.uva.nl (Dennis Koelma)
Subject:           .. ptr_cast ..
Keywords: ptr_cast
Organization: FWI, University of Amsterdam
Date: Mon, 21 Dec 1992 11:23:55 GMT

Hi,

Does anybody know whether the function "ptr_cast", page 442 in
"The C++ programming language" by Stroustrup, is or will be supported
by the Sun compiler ?

If not, is there some "workaround" library available ?

						Dennis


Dennis Koelma
Faculty of Mathematics & Computer Science, University of Amsterdam
Kruislaan 403, 1098 SJ Amsterdam, The Netherlands
email:	koelma@fwi.uva.nl
Newsgroups: comp.lang.c++
From: tim@iss.nus.sg (Tim Poston)
Subject: Re: IS C++ a language for the "average programmer"
Organization: Institute of Systems Science, NUS, Singapore
X-Newsreader: Tin 1.1 PL4
Date: Mon, 28 Dec 1992 05:36:45 GMT

ort@netcom.com (David Oertel) writes:
:  Newton used to 
:  solve problems using calculus and then publish his solutions using 
:  algebra.  He didn't reveal calculus until the end of his life when he
:  was under competitive pressure from Leibniz.  I don't think that
:  anyone know for sure why he delayed, but he was extremely eccentric.

Calculus was on very shaky ground when Newton first used and invented it,
as Bishop Berkeley pointed out a generation later
("The Analyst: a Discourse Addressed to an Infidel Mathematician").
It was very very unclear what constituted a real proof in calculus at that stage,
and it wasn't until the late 19th Century that the subject was properly tidied.
Newton liked proofs he could trust, and that were comprehensible to his peers.

The fact that he could prove so many answers without calculus
(after finding them with calculus) doesn't mean that everything
can be done that way.
Anybody who thinks they can prove that every complex polynomial
has at least one root without using analysis
(the study of the kind of proofs that apply to calculus),
see me after class.

Tim


_____________________________________________________________________
    WARNING!  This algorithm only valid for large values of 2.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From: ren@function.mps.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c++
Subject: Re: Matrix Addition  Was Re: Complex Addition.
Date: 21 Dec 1992 20:46:23 -0500
Organization: Department of Mathematics, The Ohio State University
NNTP-Posting-Host: function.mps.ohio-state.edu
Keywords: operator, memory leak


In article <1992Dec17.204049.20009@murdoch.acc.Virginia.EDU> gs4t@virginia.edu (Gnanasekaran Swaminathan) writes:
>One technique advocated several times in this forum and
>by several good books is to use reference counting and 
>return by value in case of big objects like Matrix.
>
>For example,
>
>class Matrix {
>	struct MatRep {
>		int	ref;
>		int  	rows, cols;
>		double*	d;
>	
>		MatRep (int r, int c)
>		: ref(1), rows(r), cols(c), d(new double[rows*cols]) {}
>		~MatRep () { delete [] d; }
>	}* rep;
>public:
>	Matrix (int r, int c): rep(new MatRep(r,c)) {}
>	Matrix (const Matrix& m): rep (m.rep) { ++rep->ref; }
>	~Matrix () { if (--rep->ref == 0) delete rep; }
>
>	double	operator () (int i, int j) { return rep->d[i*rep->rows+j]; }
>	Matrix& operator =  (const Matrix& m) {
>		if (this != &m) {
>			this->Matrix::~Matrix (); // self destruct
>			rep = m.rep; ++rep->ref;
>		}
>		return *this;
>	}
>
>	friend Matrix  operator + (const Matrix& a, const Matrix& b);
>};
>
>// note the return by value here
>Matrix operator + (const Matrix& a, const Matrix& b)
>{
>	Matrix sum (a.rep->rows, a.rep->cols);
>	for (int i=0; i < sum.rep->rows * sum.rep->cols;  i++)
>		sum.rep->d[i] = a.rep->d[i] + b.rep->d[i];
>	return sum;
>}
 I am new to c++, my questions are:
(1) In the destructor ~Matrix(), what happens to the memory pointed by d? It is my understanding
that the memory pointed by d should also be deleted explicitly. Although I am not quite sure.

(2)In the operator + definition,  sum.ref is initialized to 1. In order to be alive after exiting
the function, the sum.ref at least should be 2. Where is the ref incremented exactly and by which
function?

Thanks for your help!
Organization: University of Central Florida--Computer Services
Date: Wednesday, 23 Dec 1992 19:29:30 EST
From: Bill Laird <COP80196@UCF1VM.BITNET>
Newsgroups: comp.lang.c++
Subject: feedback wanted on appropriate OOPL

I am taking object oriented programming in the upcoming semester,
and wanted to get some feedback from you all.

Much to my shagrin, I have found out that Smalltalk will be the
programming language  used. I have read that Smalltalk implements
dynamic typing, and that everything, even language defined types
such as int or float are considered objects.

In the latest edition of the C++ Journal, on page 59 in the article
"Why C++ must be the choice", the author states "Smalltalk may
retain an interest because of its rapid prototyping capabilities, but
for industrial applications it is far too slow and uses too much
memory. Furthermore, the dynamic environment of Smalltalk
where everything is an object means that everything can be changed
by a developer, including basic features of the language."

For the author's need, C++ was the appropriate choice. But here is
where I would like some feedback. I know that many C++
programmers have Smalltalk experience, so I want to find out
which language you think would be the most beneficial to students.
Keep in mind that many of the students probably won't know
anything about OOP, and that in addition to learning a new language,
all of the methodology of OOP needs to be learned. Also consider that
all of the students have used C in the past, and the temptation to make
C act like C++ may be a problem to some.

Personally, I don't need the intro to OOP with Smalltalk as the tool. I
would much rather move on to C++. I plan on making a case to my
instructor if I the OOP  community provides some insight supporting
this idea.  I want to do C++ programming when I graduate, and feel
that Smalltalk is going to slow me down (pun intended) in this endeavor.

Please send any feedback to my compuserve account if you don't feel a
reply belongs on the net. My usenet account is about to expire, but
one of the bbs's in my area caries this echo so I will be able to read
post's, but not sure if I can be replied to.

I can be reached at compuserve by e-mailing 71753.130@compuserve.com

Thanks in advance for any info,
Bill
From: gordon@siemens.com. (Igor Gordon)
Newsgroups: comp.lang.c++
Subject: Looking for software to test CMs
Date: 21 Dec 92 22:21:43 GMT



We are in the process of evaluating several CM systems. I am looking for
software (source + [repository] + make files) to be used in the evaluation 
process.

Could anyone point me in the right direction for public domain
software that I could use for my purposes. The desirable characteristics
of such software are, in order of importance:

1. Number of modules (files): 500 -  3000

2. Executables are built using make

3. The software is organized hierarchally (not all files are
   dumped into one directory).

4. Language C/C++ (other languages are ok if public domain
   compilers are avaiable on Sun).

5. Large number of versions per file.

Pointers to any reasonably large piece of software are appriciated, 
even if it does not meet the above criteria.

-----------------------------------------------------------------
I speak only for myself

Igor V. Gordon			tel:   (609) 734-3321
Siemens Corporate Research      fax:   (690) 734-6565
Princeton NJ			email: gordon@siemens.siemens.com



Newsgroups: comp.lang.c++
From: kirby@xerox.com (Mike Kirby)
Subject: Re:  Give me safe C++
Reply-To: kirby@xerox.com
Organization: Xerox Corporation, Webster NY
Date: Tue, 22 Dec 1992 18:22:56 GMT

In article 20895@ucc.su.OZ.AU, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
>In article <1992Dec18.134937.14313@bony1.bony.com> richieb@bony1.bony.com (Richard Bielak) writes:
>>
>>If you are writing safety critical software - let's say software that
>>controls the brakes in *my* car - I'd rather have you code in PASCAL
>>and run with all the runtime checks on. I don't want my brakes to stop
>>working just because you forgot an ampersand.
>>
>	I'd rather have the code
>implemented in a language in which all the run-time checks
>had been optimised away by PROVING they were not required.
>
>	What would you have your brakes do if the run-time
>checks detected a program error? I think if you lived
>you would be entitled to sue the manufacturer.
>-- 
>;----------------------------------------------------------------------
>        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
>	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
>;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------


In most saftey critical systems, you ASSUME that there will be errors in the
software.  With this assumption in mind, you create physical fail-safe's or
programatic failsafes to ensure that specific problem states can never be
entered.  

The problem with formal mathematical methods for proving software implementation,
is that the proof only ensures that the implementation is a valid implementation
of the requirements.  It does not ensure that the requirements are correct. 
Faulty requirements will lead to failure, and formal proofs will NOT catch that.

This discussion is starting to drift out of the realm of C++ discussions thouugh..

Mike Kirby
Xerox Corp
E-mail: kirby.roch803@xerox.com
From: heliotis@xerox.com (Jim Heliotis)
Newsgroups: comp.lang.c++
Subject: Re: Delegation? Composition? Layering? Contain
Date: 30 Dec 92 19:39:58 GMT
Reply-To: heliotis@xerox.com
Organization: Xerox Corporation, Webster NY

I usually call it "inclusion", because it sounds good to discuss
"inheritance vs. inclusion" (I also sometimes talk about "is-a" vs.
"has-a").

============================================================================
Jim Heliotis                                       Voice Phone: 716-383-7410
Xerox Corporation                                   FAX Phone:  716-383-7395
435 W. Commercial St.                                     Mail Stop: 803-01A
East Rochester, NY 14445              Electronic Mail: JEH.ROCH803@Xerox.COM
============================================================================
Newsgroups: comp.lang.c++
Newsgroups: comp.lang.c++
Subject: Microsoft C++ bug
From: robertd@kauri.vuw.ac.nz (Robert Davies)
Date: Fri, 25 Dec 1992 11:50:00 GMT
Organization: Victoria University of Wellington

/*
Strange microsoft bug

The following program calls the constructor for Base once and the destructor
twice.

It works fine with Borland.
*/

#include <iostream.h>

class Derived;

class Base
{
public:
   Base()
      { cout << "Constructer called; this = " << (unsigned long)this << "\n"; }
   ~Base()
      { cout << "Destructor  called; this = " << (unsigned long)this << "\n"; }

   operator Derived() const;       // OK if this statement is omitted
};

class Derived : public Base        // OK if not derived from Base
{};

class AnotherClass
{
public:
   AnotherClass(const Base&) {}
};

main()  {  Base M;    AnotherClass C(M);   return 0;  }
From: hwrvo@kato.lahabra.chevron.com (W.R. Volz)
Newsgroups: comp.lang.c++
Subject: Borland C++ compiler products ?
Date: 31 Dec 92 20:44:59 GMT
Organization: Chevron Oil Field Research Company

Could someone explain the difference between:

Turbo C++ for dos or windows

Borland C++

Both are from Borland. A fact sheet I got from Borland at OOPSLA said
that Turbo C++ is based on cfront 3.0 but the back of a box at a local
store said cfront 2.1. If they are the same product, why the difference
in price of about $200. They have to be giving something for the extra
bucks.

Any help is appreciated. Thanks in advance.


-- 

======================
Bill Volz
Chevron Oil Field Research Co.
Exploration Research/Geophysics Division.
P.O. Box 446, La Habra, CA 90633-0446
Phone: (310) 694-9340
Newsgroups: comp.lang.c++
From: steve@taumet.com (Steve Clamage)
Subject: Re: Sizeof and Virtual functions
Organization: TauMetric Corporation
Date: Tue, 29 Dec 1992 21:15:05 GMT

suresh@papaya.iss.nus.sg (Suresh Thennarangam - Research Scholar) writes:

>One of the things that distinguishes virtual functions from other
>normal member functions of a class is that some compilers that I
>know of, store an extra pointer that is  probably used to index 
>a vector table...

>Is this an implementation-specific issue only ?  

Yes.  A pointer to an array of pointers to the virtual member functions
of a class is the usual implementation method.  It is not required by
the language, but is easy to implement and efficient at run time.

>A C++ programmer should  not have to know of these ugly little pointers
>lurking around in his structures.

Right, but see below.

>These monsters add 4 bytes each
>(on a 32 bit machine) to your structure; sizeof no longer tells the 
>truth and seemingly innocent  actions like fwrite'ing such structures 
>to  a file can quickly assume rather pernicious connotations. 

'sizeof' better tell the truth.  It must report the amount of storage
required by an object of that type.  If the object has extra data added
by the compiler, that is part of its size.  This is conceptually no
different from the padding a compiler might add to get suitable alignment
of individual members.  You are not allowed to assume the size of any
type other than "char" (which is always 1 by definition).  In C as well
as C++, struct types might have a size different from that calculated
by adding the size of each member.

>If I write classes with virtual functions to interpret and save 
>file formats like XWD, TIFF, GIF , etc and innocently use sizeof() 
>to calculate the size and write to a file I will be writing along 
>addresses in my machines data area. Obviously, no one will be able
>to read those files either. Of course an experienced C++ programmer
>would know how work around this problem  but this just an illustration. 

You are ignoring a critical part of C++.  Objects of class type must be
constructed.  Reading data from a file into raw memory is not in general
the same as constructing an object.  The exact layout of members of a
class is not promised in general either, so blindly overwriting a class
object is likely to produce poor results in general.

If you have an object of class type which has no base classes, no
virtual member functions, no members of pointer type, and no static data
members, you should be able to get away with a bit-copy to external
storage and bit-copy back.

A C++ class is an abstraction mechanism.  This means you give up 
intimate control of the representation in exchange for the ability to
deal with object using a portable, high-level approach.

C++ allows control of pure data types in exactly the same way as C.
You can, for example, create a C-style struct containing just the data
of interest, and derive a class from it which has all the functionality
you want.  You can still write and read back the data as you would in C.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: antoy@antares.cs.pdx.edu (Sergio Antoy)
Newsgroups: comp.lang.c++
Subject: Chosing a C++ compiler
Date: 3 Jan 93 19:54:32 GMT
Article-I.D.: antares.ANTOY.93Jan3115432
Reply-To: antoy@cs.pdx.edu
Organization: Portland State University, CS Dept.

I need to chose a compiler for two C++ courses, one at the
sophomore level and another at the graduate level. The FAQ has a
list of compilers (Q5) and a list of levels (Q126), but does not
say the level of each compiler and it is rather sketchy.  E.g., it
repeatedly refers to "USL", but could not find what this is.  To
vendors: I am interested only in compilers for Suns and/or
Sequents, but please read below.

I assume others may want this information.  Please, e-mail me and
I will summarize all data I receive---in particular, phone and/or
address of supplier, cost (both educational and commercial), and
any piece of relevant information.  Thank you.

Sergio Antoy
Dept. of Computer Science
Portland State University
P.O.Box 751
Portland, OR 97207
voice +1 (503) 725-3009
fax   +1 (503) 725-3211
internet antoy@cs.pdx.edu
From: t09@clark.edu (Owen Fairfield)
Newsgroups: comp.lang.c++
Subject: highlighting text?
Date: 27 Dec 92 11:04:25 GMT
Article-I.D.: clark.1992Dec27.110425.1702
Organization: Clark College, Vancouver, Wa.  USA


I am kinda new to the world of C++ and I was hoping that someone could possibly
help me out, I am looking for a function that will highlight text for me, is 
there such a function or do I need to make this by myself?  Next question, if I
do need to make this by myself, is there some way that I could use a NOT to 
change the bits and therefore just change the colors of the screen?  Any help 
would be greatly appreciated, like I said I am new to C++ so if this is a dumb
question please do not beat up on me too bad.


		
Newsgroups: comp.lang.c++
From: ian@syacus.acus.oz.au (Ian Joyner)
Subject: Re: where the name C++ came from
Organization: ACUS Australian Centre for Unisys Software, Sydney
Date: Tue, 29 Dec 1992 01:46:25 GMT

tostan@dumbo.lerc.nasa.gov (Stan Mohler) writes:

>I had a dream last night in which I figured out a possible reason for C++
>having the name C++.  Yesterday I was reading about C and C++.  I skimmed
>across a few lines showing the use of operators such as ++.  i++ measns to
>increment variable i.  Incrementing something means to increase it, expand it
>if you will.  Is it possible that "C++" simply means an "expanded C" in the
>most economical and cute way a C programmer might think of?

I suggest you read Orwell's 1984 for a 'double plus ungood' explanation ;-)
-- 
Ian Joyner  ACUS (Australian Centre for Unisys Software)    ian@syacus.acus.oz
"Where is the man with all the great directions?...You can't imagine it,
 how hard it is to grow, Can you imagine the order of the universe?" ABWH
Disclaimer:Opinions and comments are personal.
Newsgroups: comp.lang.c++
From: pauljo@microsoft.com (Paul Johns)
Subject: Re: feedback wanted on appropriate OOPL
Date: 29 Dec 92 01:57:06 GMT
Organization: Microsoft Corp.
Distribution: usa

I'll second Ross's advice, but add that you should
complete your class assignments in BOTH Smalltalk
and C++.

Doing that will give you a keen appreciation for
the differences between the two and the strengths
and weaknesses of both.

You may want to alternate which one you do first.

Of course, this advice assumes that you, like all
students, have infinite time at your disposal.  :)

I'll second Jim's advice as well by adding that
you should write both the Smalltalk and the C++
(but especially the C++) in a style appropriate
for the language.  This may require some design
changes, not just a simple translation.
Newsgroups: comp.lang.c++