What is Expressiveness in a Computer Language

Joachim Durchholz jo at durchholz.org
Fri Jun 16 18:09:26 EDT 2006


Darren New schrieb:
> Joachim Durchholz wrote:
>> Give a heterogenous list that would to too awkward to live in a 
>> statically-typed language.
> 
> Write a function that takes an arbitrary set of arguments and stores 
> them into a structure allocated on the heap.

If the set of arguments is really arbitrary, then the software can't do 
anything with it. In that case, the type is simply "opaque data block", 
and storing it in the heap requires nothing more specific than that of 
"opaque data block".
There's more in this. If we see a function with a parameter type of 
"opaque data block", and there's no function available except copying 
that data and comparing it for equality, then from simply looking at the 
function's signature, we'll know that it won't inspect the data. More 
interestingly, we'll know that funny stuff in the data might trigger 
bugs in the code - in the context of a security audit, that's actually a 
pretty strong guarantee, since the analysis can stop at the function't 
interface and doesn't have to dig into the function's implementation.

>> Give a case of calling nonexistent functions that's useful.
> 
> See the Tcl "unknown" proc, used for interactive command expansion, 
> dynamic loading of code on demand, etc.

Not related to dynamic typing, I fear - I can easily envision 
alternatives to that in a statically-typed context.

Of course, you can't eliminate *all* run-time type checking. I already 
mentioned unmarshalling data from an untyped source; another possibility 
is run-time code compilation (highly dubious in a production system but 
of value in a development system).

However, that's some very specialized applications, easily catered for 
by doing a dynamic type check plus a thrown exception in case the types 
don't match. I still don't see a convincing argument for making dynamic 
typing the standard policy.

Regards,
Jo



More information about the Python-list mailing list