Version française
Home     About     Download     Resources     Contact us    
Browse thread
Warning wished
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frédéric_van_der_Plancke <fvdp@d...>
Subject: Re: [Caml-list] Warning wished
Dmitri Boulytchev wrote:
>
>> Applying g to 1 you will definitely have f x of type int and you have to
>> take care of the returned integer. Unfortunatly caml emits no warning in
>> this case (even if I understand why) :(.
>>   
>    Sure :) But as far as I understand this warning means "this 
> non-unit value will definitely be omitted, and this
> can be possibly wrong". Under this interpretation the compiler has to 
> ensure undoubtedly that the value is
> always non-unit.
>    BTW you may (temporarily) change your code into something like
>
>    let f x = [x]
>
>    of even into
>
>    let f x = object method get = x end
>
>    and find all the suspicious places :)
>
>    Best regards,
>    Dmitri.
There's the question of what the compiler _does_, what the compiler 
_could_ do and what the compiler _should_ do.

I don't think "this 'a could be unit" is a good reason for skipping the 
warning. On the contrary, "this 'a will probably sometimes be a real 
value" seems a sufficient reason to add a warning. If needed, the 
programmer can easily suppress the warning by adding "ignore" or adding 
a ": unit" type constraint (whichever applies).

(Remains to see whether adding the warning to OCaml is worth the manwork.)

Frédéric