If Prolog has clear distinction between strings, numbers, atoms, lists and compound structures how can it be called untyped. And how does it differ from dynamically typed languages like Lisp for example.
Which part of the definition of "dynamically typed language" does Prolog conflict with? And which part of the definition of "untyped language" does Lisp conflict with?
Any insight is appreciated.
Update
I already know what's the difference between dynamic, static, strong and weak typing. My question is about a special case which is Prolog. I just want to understand how is Prolog considered to be untyped though it doesn't seem to have a clear difference from dynamically typed languages.
Here's a reference that Prolog is untyped http://en.wikipedia.org/wiki/Prolog#Types
Prolog is mostly untyped in the sense that you can pass any kind of term to any predicate and, usually, the worst case is that the predicate will not succeed. However, arithmetic predicates, such as is
and =:=
expect numeric arguments and may blow up - so there is a notion of types there.
Non-pure predicates might also expect objects of type "file handle" and blow up otherwise.
So, calling Prolog "untyped" is not strictly true.
When you write a predicate like
head([H|_], H).
you don't specify any types anywhere. You can call head([1,2,3], X)
, you can call head("foo", X)
and you can even call head(1, [1,2,3])
. All of them run just fine. The last one won't cause any error, it will just return false.
. I think that's what was meant by “untyped”.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With