|
|
|
|
|
by Jtsummers
1074 days ago
|
|
How is OCaml strongly typed if it doesn't have declared types?!?!? (EDIT: In case it's not obvious, I'm being sarcastic, I'm pretty sure some people in this discussion won't get that though.) let f x = x + 1;; (* What's the type?!?!? *)
Turns out that "strong typing" is a shitty phrase that people should stop using because it means too many conflicting things, and, consequently, means nothing. Static and dynamic typing have well-defined meanings, stick with those terms instead of ones that mean nothing.But for a demonstration (compare to Perl) try this in your Python REPL: >>> 1 + "1"
Does it work? Probably not unless you futzed with the language implementation. In Perl it does, though. So to the extent that "strong typing" means anything, Perl is "weakly typed", Python is "strongly typed", and both are dynamically typed. It's an orthogonal characteristic of the type system and language from when type checking occurs.---------- EDIT: BTW, formatting code blocks on HN is really easy. Prefix each line of code with two space characters. __Replace those _'s with spaces
The result is much cleaner than your comment: def foo(x):
return x + x
No extra newlines needed, more compact, easier for most people to read. |
|
re: 1 + "1"
I didn't get your point really. My reply was to counter claim that Python is supposedly "strongly typed" and I don't understand how this strong typing helps developers. I know that languages can infer types, which is tangential subject. I dont know why you brought this up