"Strong typing vs. strong testing"

Pascal J. Bourguignon pjb at informatimago.com
Fri Oct 1 05:33:26 EDT 2010


Seebs <usenet-nospam at seebs.net> writes:

> On 2010-10-01, Don Geddis <don at geddis.org> wrote:
>>         in C I can have a function maximum(int a, int b) that will always
>>         work. Never blow up, and never give an invalid answer. If someone
>>         tries to call it incorrectly it is a compile error.
>
> I would agree that the third sentence is arguably wrong, simply
> because there's no such thing (outside #error) of a mandate to stop
> compiling.  However, my understanding was that the dispute was over
> the second sentence, and that's certainly correct.
>
> The obvious simple maximum() in C will not raise an exception nor return
> something which isn't an int in any program which is not on its face
> invalid in the call.  This is by definite contrast with several of the
> interpreted languages, 

This has nothing to do with the fact that these languages have
implementations using the interpreter pattern instead of a compiler.

Matter of fact, most Common Lisp implementations just do not have any
interpreter!  (Which doesn't prevent them to have a REPL).


> where a function or subroutine like that cannot
> specify that its argument must be some kind of integer.

This is correct, but this is not a characteristic of dynamic programming
languages.  There are dynamic programming languages where you can
declare the type of the parameters, to allow for static checking.  For
example in Common Lisp (where these declarations are advisory, so the
compiler is free to take them into account or not, depending on what it
can infer from its own side, so any problem here is just a warning: the
program can always handle the problems at run-time).



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/



More information about the Python-list mailing list