C
Chris Smith
Christopher said:Right, but that is because Java does not support subtypes other than
subclasses. In languages with more general type systems, such as Curl, you
cannot get away with using the terms "type" and "class" to distinguish between
runtime and static types. I suppose you can say the "variable type" is the
static type and the "value type" is the dynamic type, and I think that is
something like what you are suggesting, but I think it is clearer to speak of
the "static" or "compile-time" type vs. the "runtime" or "dynamic" type and
thus avoid having to distinguish the difference between a variable and a
value.
Well, you're saying the same thing, but using different words. I guess
all this goes to show is that terminology differs. It would be nice if
"type" could mean one thing to everyone, but your attempt to find a
common definition between languages has led to rendering the term
useless. I guess you just have to keep the language in mind, and use
"type" as it's used in that language. In Java and most other languages
I've worked in, a type is, by definition, a compile-time concept.
Variables and expressions have types, not values.
If Curl uses different terminology, so be it. Who am I to say that
people who use "type" in a different way when talking about Curl are
wrong? I don't even know the language! I can only say that they are in
the minority. Using "type" when you mean "class" in Java or C++, for
example, is definitely wrong, and somewhat confusing to boot.
I think of dynamic typing as referring to the ability to make decisions based
on the runtime type of values.
Really? That's nothing like the way "dynamic typing" is used anywhere
else that I've seen. Generally, "dynamic typing" means that the
compiler doesn't track types. A language where there's tracking of
types and that type information is used to determine the meaning of code
is statically typed, regardless of the existence of a command to get the
kind of value held by a variable (which is not a type anyway under the
normal definition).
It's rather unfortunate that the term "dynamic typing" ever existed, but
we can track it back to human tendency to not want to be without
anything (even if it's not necessarily beneficial), so that designers
and programmers in languages without types had to make up some reason
that they really do have it... thus eroding the concept in general.
The Curl language has an abstract type called 'any', which is the supertype of
all other types. Omitting a type declaration in Curl is equivalent to
explicitly declaring it to be of type 'any'. Such variables do have a fixed
static type of 'any', but may hold a value with any runtime type. So the
above definition would not work for Curl or other languages with a similar
type system.
Based on your later description, it appears that Curl's 'any' type is an
explicit renunciation of types. Too bad it has to be called a type just
to confuse people.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation