Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Future of labels
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mattias Waldau <mattias.waldau@a...>
Subject: [Caml-list] Just wasted half-an-hour on returned curried functions
I removed the last int-argument of a function,
but only changed at the calls and in the
body, however not in the arguments, thus I had an unused arg
called ~(idx:int), i.e.

let bar a ~(idx:int) =
	{ var = a ; .... }

I created data using this function and these
(now curried) arguments were put into an array, and there is where I
got the type error. It took me 30 minutes to find the true source.

I could have found the error if I would have typed the result of the
above mentioned function either at the return value or in the let,
i.e. writing

let bar a ~(idx:int) :annotated_var =
	{ var = a ; .... }

or

let x:annotated_var = ..... in

However, the compiler could have found the error for immediately by
either

1. Told me that ~(idx:int) is an unused argument
2. or, had a special syntax ( for example '=()' ) for curried values, for
example,
   and by that immediately complain in the let above.

I know that alternative 2 is an absurd suggestion in the church of FPLs :-)
but I don't like wasting time. Could someone give me some example code
(except lablgtk, which is a nice but very hard to understand program)
where the majority of the returned values are functions.


/mattias

P.s. I don't understand how to get warning using ocamlc, for example in the
below code I both override methods and hide instance variables, but get no
warnings.

let foo () =
	let x = 0 in
	let x = 1 in
	x

let foo () =
	let x = 0 in
	let x = 1 in
	x

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr