home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Give me safe C++
- Message-ID: <1992Dec15.134713.2561@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <WARSAW.92Dec11124441@anthem.nlm.nih.gov> <1992Dec12.145403.26483@ucc.su.OZ.AU> <WARSAW.92Dec12174137@anthem.nlm.nih.gov>
- Date: Tue, 15 Dec 1992 13:47:13 GMT
- Lines: 64
-
- In article <WARSAW.92Dec12174137@anthem.nlm.nih.gov> warsaw@nlm.nih.gov (Barry A. Warsaw) writes:
- >
- >>>>>> "John" == John MAX Skaller <maxtal@extro.ucc.su.OZ.AU> writes:
- >
- > John> While tending to support your liking of the C++ 'hybrid'
- > John> approach, I'm not so sure about 'seamlessly', are you?
- >
- >I think it is rather seamless in the sense that I can solve problems
- >(or typically, subproblems of a larger, integrated system) using a
- >functional, ADT, and/or OOP approach, and I can develop all these
- >parts in a single language. Everything doesn't have to be a class in
- >C++ and not all classes have to use inheritance and polymorphism. My
- >only point was that I don't have to jump through hoops to solve a
- >problem using these different abstraction levels. Maybe we're talking
- >about different things when we say "seamless"?
-
- No, I agree in principle and practice with you.
- But there continue to be annoying problems. An example:
- I want an abstract base class X with an operation f that returns
- an X, so I can provide some implementation
-
- class Y : X { .. Y f(); .. }
-
- where f is virtual. But I cant.
- How do I declare X::f? If I use
-
- X X::f()
-
- it is illegal, due to different return types. If I use a reference
-
- X& X::f();
- X& Y::f();
-
- it is fine syntactically, but C++ has no garbage collection,
- so if in Y::f is have
-
- .. return new Y;
-
- then the object gets lost in an expression and cant be deleted.
- This problem doesnt arise in Eiffel, *because* it has garbage
- collection.
-
- In C++ you can sort of work around this, but only be introducing
- another layer of classes that act as references to the real objects.
- But thats not seamless integration, I have to rework ALL my code
- to accommodate this design change.
-
- This explains why good vendor libraries that do this sort of
- work for you are incompatible, (and are thus also 'bad')
- they use different techniques
- for repressenting classes .. because the base language itself
- is not adequate.
-
- (Adding GC solves some of these problems, but many remain.
- There is probably no general solution, of course.
- At least on smaller projects these issues tend not to arise,
- however. Large scale integration is a different class of
- problem I think.)
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-