Typing system vs. Java

Steve Holden sholden at holdenweb.com
Wed Aug 1 21:57:24 CEST 2001


"Christopher Barber" <cbarber at curl.com> wrote in message
news:psoy9p34lvy.fsf at jekyll.curl.com...
> "Alex Martelli" <aleaxit at yahoo.com> writes:
>
> > "Christopher Barber" <cbarber at curl.com> wrote in message
> > news:pso66c9rpo8.fsf at jekyll.curl.com...
> > > Well, I actually used Python on a number of projects a couple of years
ago
> > and
> > > did spend more time than I would have liked writing tests to detect
type
> > > consistency.
> >
> > Probably no more time than I spend cursing [expletive deleted]'s who
> > write type-tests. ...
> > "BEHAVES-LIKE-A" (i.e. IS_ADAPTABLE_TO_PROTOCOL) is what, at most,
> > one SHOULD be testing (if anything).
>
> Sure, but it is often much easier to document that var x must be a foo
than it
> is to say that it must provide some arbitrary set of attributes.  This
after
> all is one of the point of types: to create a shorthand for sets of
properties
> that you want to go together.
>
While it is true that a type such as foo is a convenient shorthand implying
a whooooole slew of properties, this itself can be a trap for the unwary.
Suppose, in your mission-critical program, you use an int to hold a value
which should only ever be between 32 and 213. The only way you have to
exercise that level of semantic control is to declare a class, and test that
no assignments violate the required constraint (unless you are using a
Pascal derivative, which allowed that kind of thing quite nicely, or you are
using program proof techniques, which are of little use to the
mathematically-deficient). So run-time value testing is required even if you
force the compiler to do type testing.

Type safety completely fails to live up to whatever promise it might have
unless programmers exercise adequate care to define types which do exactly
what they want. And most programmers are somewhat sloppy about that.

and-i'm-no-better-than-the-rest-ly y'rs  - steve

PS: Alex, I'm sorry about the "if type()..."s!
--
http://www.holdenweb.com/








More information about the Python-list mailing list