Browse thread
Undecidability of OCaml type checking
-
Andreas Rossberg
-
Dave Mason
- John Skaller
- Xavier Leroy
- Xavier Leroy
-
Dave Mason
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | John Skaller <skaller@m...> |
| Subject: | Re: irritability of structure name conflicts |
At 13:59 13/07/99 -0400, Dave Mason wrote:
>Is there some way I can force it to interpret the type constructor as
>a particular type so that it chooses the labels from the correct set?
This problem pervades ocaml. Another case of it is variants:
type A = X | Y;
type B = X | Z;
which all compiles fine, but then X is a constructor for
the B variant.
C also has the same problem with enumerations:
enum X {a,b,c}; /* a,b,c are globals */
The problem can be solved, clumbsily, by wrapping inside a module.
(In C++, inside a class or namespace)
While I'm also expressing irritation, when I compile
a file (as opposed to using the interactive system);
rebinding of symbols shouldn't be allowed:
let a = 1;;
...
let a = 1.0;;
...
print_int a;;
(* what does that strange type error mean!
a is an integer! It is right there at the top of the file!
*)
Another similar case is
open List
open Map
iter ...
Woops! I meant List.iter, not Map.iter :-)
There are several solutions, but the one that could
be implemented now with least impact would be to
issue warnings whenever a symbol is rebound
in the same scope during batch compilation.
(No warning in the interactive system; rebinding
to fix mistakes is common)
-------------------------------------------------------
John Skaller email: skaller@maxtal.com.au
http://www.maxtal.com.au/~skaller
phone: 61-2-96600850
snail: 10/1 Toxteth Rd, Glebe NSW 2037, Australia