Hacker News new | ask | show | jobs
by ComputerGuru 2209 days ago
I’m not a fan of loosely-typed languages in general, but isn’t that chart pretty typical for dynamically typed interpreted languages? I know PHP’s is a mess and I’ve seen comparison/equality horror stories posted to HN regarding even the venerable Python.
1 comments

No, many dynamically typed languages do not perform implicit conversions: Lisp and Python are languages that do it better. They still have some subtleties (Lisp has the EQ/EQL distinction, not to mention a huge number of other quality operators in Common Lisp), but I see implicit conversions as a singularly bad idea in a dynamically typed language.
Lisp certainly performs some implicit conversions in numeric computing.

   > (+ 1 1/10 3.0)
   4.1
In this example, since + is a function, it's part of its semantics.

There would be a lot of verbiage if arguments had to be coerced to all be of the same type.

In addition to numeric examples, there are situations where Lisp is forgiving/flexible. For instance in most cases, a symbol can be used in place of a function object. The symbol is resolved to a function through its function binding.

That can be regarded as an implicit conversion, or alternatively as polymorphism.

Yet another example is that Common Lisp allows some string operations on symbols.

   (string= 'abc "ABC") -> T
No conversion ever takes place in the evaluation, as far as I know, or the passage of a value (e.g. from a function argument expression into the argument). All these kinds of things happen inside specific functions according to their respective rules.