🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #689

Re: The concept of templates considered ill designed

#689
From: Stefan Monnier
Date: Thu, 08 Oct 1992 12:51
57 lines
2793 bytes
Excerpts from netnews.comp.lang.c++: 7-Oct-92 Re: The concept of
template.. Pete Becker@genghis.borl (2093)
> 	Constrained parameters alone do not make it possible to compile a
> template without regard to how it will be instantiated.

> 	class Parameter
> 	{
> 	public:
> 	    virtual void f( long );
> 	};

> 	template <class T : Parameter>
> 	class DoSomething
> 	{
> 	};

> 	class SmartParameter : public Parameter
> 	{
> 	public:
> 	    void f( long );
> 	    void f( int );
> 	};

> Presumably, SmartParameter adds f(int) because it can handle small values
> in a more efficient manner.  If DoSomething is compiled without knowledge of
> the actual template parameter being used, this smarter interface is lost.
> 	As I mentioned earlier, the other place where you pay for this is that
> all uses of the template parameter must be through pointers.
> 	Being able to compile a template without knowing how it is in fact
> being used may well be useful, but it comes at a price.  The resulting code
> will be less efficient.
> 	I think the argument in favor of compiling templates on their own has
> to focus on this point.  What do you get out of it that you cannot get by
> simply using pointers?  Easier coding, sure.  But are there significant
> differences in the kind of things you can do with them?  Or is this a solution
> in search of a problem?
> 	-- Pete


Who said there was no drawbacks ?

Of course it may add some overhead (although development will be nicer cause
of typechecking and FASTER turn around time (though precompiled template
libraries))

Every advance in languages has been associated with an increased overhead:
from assembler to C, from C to C++: every time you switch to a higher level
language you lose some speed. 

I don't think particular change will add a big overhead. that's why I
think it's useful !

	Stefan

-----------------------------------------------------
-- On the average, people seem to be acting normal --
-----------------------------------------------------
Technical Details
Message-ID: <Eep9xSi00Vp_4391Iw@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+
References: <1992Oct6.020042.11130@cadsun.corp.mot.com> <1992Oct6.174129.10404@genghis.borland.com> <UeoW1kS00awV0GbEpY@andrew.cmu.edu> <1992Oct7.170351.16316@genghis.borland.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+
From: osoelgaultier+@CMU.EDU (Stefan Monnier)
Newsgroups: comp.std.c++,comp.lang.c++
Subject: Re: The concept of templates considered ill designed
Message-ID: <Eep9xSi00Vp_4391Iw@andrew.cmu.edu>
Date: 8 Oct 92 12:51:42 GMT
Article-I.D.: andrew.Eep9xSi00Vp_4391Iw
References: <1992Oct6.020042.11130@cadsun.corp.mot.com> <1992Oct6.174129.10404@genghis.borland.com> <UeoW1kS00awV0GbEpY@andrew.cmu.edu>
 <1992Oct7.170351.16316@genghis.borland.com>
Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
Lines: 57
In-Reply-To: <1992Oct7.170351.16316@genghis.borland.com>