cro…@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <2026…@yahoo.com>,
> Michael S <alre…@yahoo.com> wrote:
[...]
>>There is a whole continuum of possibilities between strongly typed and
>>untyped.
>
> Then you should explain yourself.
>
> "Python is strongly typed. It is of little practical
> importance." What, precisely, did you mean? And why do you
> consider it of, "little importance?"
I think this is devolving into an debate that's mostly about the
meanings of English phrases like "strongly typed" rather than about the
semantics of various programming languages.
I do agree that if someone is going to say a language is "strongly
typed", they should probably explain just what they mean by that.
I'm not aware that there's any widely accepted definition of
"strongly typed". And I would argue that "strong typing" cannot
be measured along a single continuum, with "weakly typed" languages
at one end and "strongly typed" languages at the other. One language
might have strong typing enforced at run time; another might have
weak typing enforced at compile time.
> To tie this back to C, C is a weakly-typed language; add a
> number to a string literal and the result is a pointer. This
> has been a source of a _huge_ number of bugs over the years.
I can imagine a definition of "weakly-typed" that applies to C,
probably based on its rather promiscuous implicit conversions. On
the other hand, every C expression has an unambiguous type, determined
entirely by the expression itself and the rules of the language.
(The conversion/adjustment of expressions of function an array
type is arguably an exception to this, but one that's completely
specified by the language rules).
Adding an integer to a string literal yields a pointer because
(a) an array expression, such as a string literal, is "converted"
to a pointer expression in most contexts, and (b) there exists an
addition operator that takes a pointer and an integer and yields
a pointer. (And I'm skeptical that this has been a source of a
huge number of bugs.) Python allows a string to be multiplied by
an integer; "foo" * 3 yields "foofoofoo".
In a typical assembly language, you can load two floating-point values
into registers and apply a bitwise xor to them as easily as you can
multiply them. You can't do that in most higher-level languages,
including C, without extra steps that make the weirdness explicit. In
Python, you can assign an expression of any type to a variable named
"x"; the type is associated with the value, not with the variable.
C doesn't do that. I would argue that most assembly languages are
very weakly typed, but I wouldn't necessary say that C is more
strongly typed than Python is or vice versa.
--
Keith Thompson (The_Other_Keith) Keit…@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */