Hello,
When I try to compile the following program:
let f1 = function
{re=a;im=b} ->
print_float a;
print_float b
in
f1 {re=10.0;im=20.0
I get an error message:
File "tmp.ml", line 2, characters 2-13:
Error: Unbound record field label re
I know how to "fix" the program to be compilable---I have to add
type whatever = {re:float; im:float}
at the top.
Then type inference is able to figure out that "f1" has type "whatever -> unit".
Why did language designers chosen:
- typing by structure in case of tuples (tuples can be viewed as records with
unlabled fields),
- typing by name in case of records.
Why wasn't typing by structure chosen both for tuples and for records?
If it were, then type of "f1" would be "{re=float;im=float}".
Best regards.
--
Matej Košík
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs