What is Expressiveness in a Computer Language
robert.thorpe at antenova.com
Tue Jun 20 15:11:58 CEST 2006
Andreas Rossberg wrote:
> Rob Thorpe wrote:
> > No, that isn't what I said. What I said was:
> > "A language is latently typed if a value has a property - called it's
> > type - attached to it, and given it's type it can only represent values
> > defined by a certain class."
> "it [= a value] [...] can [...] represent values"?
> > Easy, any statically typed language is not latently typed. Values have
> > no type associated with them, instead variables have types.
> A (static) type system assigns types to (all) *expressions*.
That's right most of the time yes, I probably should have said
expressions. Though I can think of static typed languages where the
resulting type of an expression depends on the type of the variable it
is being assigned to.
> This includes values as well as variables.
Well I haven't programmed in any statically typed language where values
have types themselves. Normally the language only knows that variable
Z is of type Q because it's in a variable of type Q, or as you mention
an expression of type Q. There are many things that could be
considered more than one type. The integer 45 could be unsigned 45 or
signed 45 or even float 45 depending on the variable it's in, but
without context it doesn't have a precise type.
It does imply the type to some extent though, you could imagine a
language where every value has a precise type. So, you've found a hole
in my definition.
Maybe a better definition would be:-
if (variables have types || expressions have types) <lang is statically
else if (values have types) <lang is latently/dynamically typed>
else <lang is untyped>
That seems to fit usage, quite well.
Even then there are problems. Perl has static types for arrays, hashs
and scalars. But scalars themselves can be integers, strings, etc.
> Don't confuse type assignment with type annotation (which many
> mainstream languages enforce for, but also only allow for, variable
More information about the Python-list