Version française
Home     About     Download     Resources     Contact us    
Browse thread
partial application warning unreliable?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] partial application warning unreliable?
On Fri, 2005-12-09 at 13:21 +0100, Andreas Rossberg wrote:
> skaller wrote:
> > 
> > The correct type is void, however unit
> > will catch more errors than 'a.
> 
> IIRC, this has been discussed in the past, but since you iterate this 
> statement repeatedly, let me reinforce that it is incorrect.

Well it seems to achieve the desired result in Felix.

In particular, neither malc nor myself would have had
our bugs slip past the Felix type system the way they
slipped past Ocaml. However using unit instead would
have caught both our bugs I think, but fail to
eliminate:

	f: int -> 1
	g: 1 -> int

	let x = g ( f 1 ) in

which is clearly still wrong -- you should be required to write
this as

	f 1;
	let x = g () in

to explicitly sequence the side effects. Felix allows

	f: int -> 0

but not

	g: 0 -> int

and thus, the expression:

	g (f 1)

cannot type check (for any g). This forces you to explicitly
sequence side effects, which is the intended result.
BTW: it isn't clear this is entirely desirable!

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net