Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] let rec and polymorphic functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] let rec and polymorphic functions
> This isn't really "the equivalent SML", since the definition of `id x' 
> and the application `id 0' aren't in the same recursive group.  The 
> equivalent in SML would be something like

Thanks for this. I see the SML difference now - 

let fun id x = x
    and g x = id 0 + x
in
  id ()
end;

similarly doesn't work in SML with a pair of functions instead.

> OCaml seems a little inconsistent here, actually.  The application `id 
> 0' is only valid as the rhs of let rec because the compiler can 
> determine that there's no actual recursion involved.  There doesn't 
> seem to be a reason not to apply a similar analysis to type checking, 
> allowing more polymorphism for functions in the same recursive group 
> that aren't actually part of a cycle.

Which is what SML did in my "equivalent" example - and it would certainly be
nice if OCaml did the same. Is it worth raising a bug (well, feature
request) for or am I the only person who (ab)uses [let rec] in this way?

Many thanks,


David