Alex Rivera | Logout

Is Prolog an untyped language? What's the difference between Prolog and dynamically typed languages?

Asked 2011-06-10T18:02:09.640
10

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

Edit
Report

1 Answer

1

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”.

answered 2011-06-10T19:30:02.947

Your Answer