Message-Id: <3.0.6.32.19990714130436.00987970@mail.triode.net.au>
Date: Wed, 14 Jul 1999 13:04:36 +1000
To: Dave Mason <dmason@sarg.Ryerson.CA>, caml-list@inria.fr
From: John Skaller <skaller@maxtal.com.au>
Subject: Re: irritability of structure name conflicts
In-Reply-To: <199907131759.NAA00710@sarg.Ryerson.CA>
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
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET