Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.lang.objective-c,comp.object
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!portc02.blue.aol.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!howland.erols.net!newsxfer3.itd.umich.edu!chi-news.cic.net!ftpbox!mothost.mot.com!schbbs!news
From: shang@corp.mot.com (David L. Shang)
Subject: Re: Combining dynamic and static typing
Reply-To: shang@corp.mot.com
Organization: MOTOROLA 
Date: Wed, 29 Jan 1997 15:34:55 GMT
Message-ID: <1997Jan29.153455.14196@schbbs.mot.com>
References: <rmartin-2801971315170001@pool11-019.wwa.com>
Sender: news@schbbs.mot.com (SCHBBS News Account)
Nntp-Posting-Host: 129.188.128.126
Lines: 36
Xref: glinda.oz.cs.cmu.edu comp.lang.eiffel:17936 comp.lang.ada:56778 comp.lang.c++:244122 comp.lang.smalltalk:50351 comp.lang.objective-c:6311 comp.object:60534

In article <rmartin-2801971315170001@pool11-019.wwa.com> rmartin@oma.com  
(Robert C. Martin) writes:
> 
> C++ uses static typing for member function dispatch, but uses dynamic
> typing (of a sort) for template dispatch. 

I am surprised to hear that C++ template uses dynamic typing (even
it is a sort of).

What is dynamic typing after all? We need a definition here because
people use this term for different concepts, and there is always
a confusion without an explicit definition.

Anyway, C++ template has nothing to do with "dynamic".

> I say (of a sort) because
> the type are still checked at compile time, even in templates.  However,
> templates can call member functions without the need to specify the
> *type* in which those member functions are declared.  Indeed, there
> need be no supertype contains the common declaration.  Thus, in that
> regard, template invocation is similar to ST dynamic types.
> 

The type check for a class parameter in a C++ template is done at
the time of the template is expanded. This is still at compile
time, not at run-time.

If we have to compare C++ templates with SmallTalk classes, yes, they have
one common property: late-type-error-detection, that is, the error
is detected at the time they are used, but not at the time they are
designed and developed. However, SmallTalk classes are released to
clients in executable form, so the use time is run-time. But C++
templates is presented to clients in source form, and the use time
is still compile-time.

David Shang
