Xref: utzoo comp.lang.c++:12234 comp.object:2732 Path: utzoo!attcan!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.lang.c++,comp.object Subject: Re: Static typing and OOP efficiency Message-ID: Date: 1 Mar 91 23:07:43 GMT References: <1991Feb16.121825.15353@gpu.utcs.utoronto.ca> <11545@pasteur.Berkeley.EDU> Sender: aro@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 40 Nntp-Posting-Host: teachb In-reply-to: jbuck@galileo.berkeley.edu's message of 28 Feb 91 23:39:25 GMT On 28 Feb 91 23:39:25 GMT, jbuck@galileo.berkeley.edu (Joe Buck) said: jbuck> In article , jbuck> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: pcg> When you write a library in C++ you tend to make everything virtual that pcg> can plausibly be, just in case. The people at AT&T did not make certain pcg> things virtual in the 'iostream' library and a lot of people are unhappy pcg> about that. jbuck> Only people who don't understand the design. They'd be even more jbuck> unhappy if the functions were virtual because they'd get function jbuck> calls per character of I/O. Let me remark that this is the least of the overhead problems in the AT&T streambuf. Still, the cost of the virtual call could be obviated if the functions had been declared virtual inline. In many (most) cases the overloading could be statically resolved. jbuck> [ ... ] That is, iostream is the way it is to exploit both the jbuck> speed of inline nonvirtual function calls and the flexibility of jbuck> inheritance. It's far from perfect, but it is the way it is for jbuck> good reason. I don't agree with many of the tradeoffs of iostream, and in particular that some choices have been made with good reason. I must admit though that IMNHO the particular one about making certain things non virtual is probably a good choice. But I was not arguing on this point; my point was that, right or wrong, the debate about virtual in the stream and iostream classes is one of the elements that has prompted several people to say "virtual unless you are damned sure nobody will ever need otherwise". A bit like "protected unless you are damn sure nobody will ever need those names". Programmer's sociology, not the technical merits. -- Piercarlo Grandi | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk