From -1051624232096595737
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,109af18a94b8a35c
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,e5cae9ffbf1dd57e
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-10-09 15:53:56 PST
Xref: sparky comp.lang.c++:14808 comp.std.c++:1367
Newsgroups: comp.lang.c++,comp.std.c++
Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!yarra!mel.dit.csiro.au!mineng.dmpe.CSIRO.AU!dmssyd.syd.dms.CSIRO.AU!metro!extro.ucc.su.OZ.AU!maxtal
From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
Subject: Re: The concept of templates considered ill designed
Message-ID: <1992Oct9.172812.3446@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: <23808@alice.att.com> <Yeo91je00awVE_zEkI@andrew.cmu.edu> <23822@alice.att.com>
Date: Fri, 9 Oct 1992 17:28:12 GMT
Lines: 61

In article <23822@alice.att.com> ark@alice.UUCP () writes:
>In article <Yeo91je00awVE_zEkI@andrew.cmu.edu> osoelgaultier+@CMU.EDU (Stefan Monnier) writes:
>
>> What I say is just that inheritance constraint permits to check
>> the file and compile it before using it !
>
>I understand that that is what you're saying, but you haven't convinced me.
>

	Me neither, but I haven't given up on the idea that you might just
be able to compile templates.

	Consider

	template<class T> f(T *t){t->print();}

The constraint is that T must have a member function 'print()'.
Now it seems that you can compile this routine, but you
have to replace 'print' with a pointer supplied silently as a
parameter to f. The call

	f(pObject);

is checked against the constraints, if it passes this test,
f is called with the pointer pObject AND the address of
its print routine.

More general cases would require the addresses of constructors
to be passed (i'm glossing over lots of issues here).

>
>My point in giving this example is to show that statements like `constraining
>template types makes compile-time type checking possible' cannot be made
>casually -- it is the responsibility of the person making such a statement
>to provide evidence that the statement is indeed true.
>
>This stuff is **difficult**!  Don't take it lightly!
>-- 
>				--Andrew Koenig
>				  ark@europa.att.com

So I'm not making the claim it can be done, only throwing in
a suggesting of HOW it might be done. But I reject the notion
that the constraints should be named base classes, rather,
the constraints are the silent parameters mentioned
above, they are the 'functions' that the type T must
have. (Yes this is a crude description, its just an idea.
Can it be made to work, if not why not, if so what
we gain is type checked templates, we loose efficiency,
at least: what else, and is it worth it?)

BTW: the constraints of course DO form a kind of
abstract, unnamed, 'base' class that you *might* have 
derived the type T from had you thought of it.


-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------


