🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Robert Pearlman Fri, 01 Dec 1995 01:14
One more thing C++ really needs
#2791
Author: Robert Pearlman
Date: Fri, 01 Dec 1995 01:14
76 lines
3258 bytes

This is required strictly from a practical viewpoint.  The problem is
simply that changing a header --in any way-- makes every dependent code file 
recompile.  That includes adding the occasional forgotten
function, used only when coding the public methods of the class.  
So one is often faced with a nasty choice -- write a
tiny function and pay (half hour, hour, more?) or write ungood 
code.  Self-discipline requires the function, but it does hurt.  Can we
avoid it without changing all the nine zillion forms of make?  

One can touch back the header, but that's also unclean.  Also, some
integrated environments, certainly Borland's, don't always respect the touch.

A similar, but much worse, problem occurs with templates.  It's worse
because the template code is so much more extensive.  No problem in
a library, of course, but if one is writing one's own templates it
gobbles up rebuild time.  I beat this one by breaking up a template into
whatever.h and whatever.hh.  whatever.h  has the declarations, whatever.hh
has the function definitions.  Then there's a single source file for each 
template- generated class, instantiating all the functions.  It's only 
these files which #include whatever.hh, and only these which recompile
when it changes.

Could we do the same for non-template headers?  Only with some awkardness
and danger.  This is pretty ugly:

class XX {
	int		dataMember1;
	void	functionMember1();
  public:
			XX() { - - - }
#if ALL_OF_XX
	#include	"restOfXX.h"
#endif
};

Now your Makefile dependencies need not usually list restOfXX, but you're
terribly exposed to natural errors.  The compiler and the pre-processor
don't talk to each other, so there's no way to forbid data members, virtual
functions, etc. in the conditional region.  So this won't do.

So perhaps we could have a language feature like this:

class XX {
	int		dataMember1;
	void	functionMember1();
  public:
			XX() { - - - }
};

When needed (probably in restOfXX.h):

struct XX << {	// '<<' means that this is an extension
	int		functionMember2(int) {dataMember1 = 0;}
}

This looks risky -- after all, you could have different extensions
in different places.  That's no more likely than having different 
definitions entirely in different places.  You can do it and the
language lets you get away with it, for a while 

Extensible definitions are less risky.  The compiler can easily keep bad 
things out of the extension -- no data members (mess up space calculations 
based on the unextended version), no virtual functions (ditto),  Static 
data members look OK.  

Is the world ready for this?

--
rp

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Re: One more thing C++ really needs
#2810
Author: Shankar Unni
Date: Sat, 02 Dec 1995 10:05
43 lines
2300 bytes
Robert Pearlman (rp@iscp.bellcore.com) wrote:

> This is required strictly from a practical viewpoint.  The problem is
> simply that changing a header --in any way-- makes every dependent code file 
> recompile.

There is indeed a group of vendors who are talking to each other about
implementing some sort of "release-to-release binary compatibility", which
basically addresses changes like this in the class interface, allowing the
classes to change in certain ways without forcing all client code to
recompile.

This is especially important when releasing class libraries, especially
shared libraries, where the customer may not have an option to rebuild the
application.

Some partial solutions exist today in certain implementations. SGI (I
mention it first because I worked on it :-) has the "dynamic classes"
feature, IBM has SOM, and Taligent also gives you a way to add a virtual
member function to the end of your current list of virtuals (reliably).

The idea of the RRBC group is to come up with a wider, and more
standardized, set of supported changes.

The downside? Code generation for such "RRBC" classes potentially may not
be as optimal as for the current C++ implementations.  Also, there may be
some language restrictions in the use of such classes (like maybe you
cannot have a case label value or an array dimension in a declaration that
is "sizeof class" or "offsetof (class, member) (since the size can
change)).

--
Shankar Unni				E-Mail:	shankar@sgi.com
Silicon Graphics Inc.			Phone:	+1-415-933-2072
URL:	http://reality.sgi.com/employees/shankar



---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads