Tracy R Reed wrote:
Andrew Lentvorski wrote:
In addition, why can't a language record what types are flying past
while a program is running and complain when something floats past
that doesn't match? While this might be tough when you have fully
compiled code, it's a little different when you have VM's running the
code.
Isn't this what Python's "duck typing" is all about?
Sorta. Python's typing is dynamic and weak. The dynamic gets you
flexibility and generally less verbosity. The weak, however, has its
downsides.
For example, the fact that None, for example, works just fine in a
boolean context frustrates me more than I would expect. There are times
when I want to be able to say, "I want to return a boolean and I meant
it. Returning 1, 0, None, etc. is *NOT* acceptable."
In addition, you can lose optimization opportunities when faced with
weak typing. If I know that 100% of the time I have integers as
arguments to a function, I can throw away the time wasted to check that
I have integers rather than doubles. Weak typing can't do that.
Languages exist in which typing is dynamic and strong. Common Lisp is
further toward the strong side and can use optimization directives to
take advantage of that. I believe that Haskell and OCaML are also
dynamic and strong in terms of typing.
-a
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg