Browse thread
Re: Re : Weak types ?
- Pascal Cuoq
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pascal Cuoq <Pascal.Cuoq@e...> |
| Subject: | Re: Re : Weak types ? |
> let toto y = > let id x = x in > id id y ;; > > this will be of type 'a ->'a > What is the difference with this : > > let toto = let id x = x in id id ;; > > I thought caml will understand that there is no difference ! > > why does caml make this difference ? the same examples, rewritten: let id = fun x -> x ;; let toto = fun y -> id id y ;; caml: ha, I know the answer to this one : toto is a function. The evaluation of "fun y -> anything" can not create references, so type variables can safely be generalized. let toto = id id ;; caml: hmmm, I wonder what this toto may be... It is the result of an application, and I don't know whether I am qualified to look deeper into the code to check about that. It might be anything, I'd better not generalize variables. About this algorithm, you can think of Caml as of Winnie-the-Pooh : it can answer difficult questions in the particular cases where the answer is obvious (ie, syntactic). Otherwise it doesn't know. Pascal