caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Skaller <skaller@maxtal.com.au>
To: Dave Mason <dmason@sarg.Ryerson.CA>, caml-list@inria.fr
Subject: Re: irritability of structure name conflicts
Date: Wed, 14 Jul 1999 13:04:36 +1000	[thread overview]
Message-ID: <3.0.6.32.19990714130436.00987970@mail.triode.net.au> (raw)
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





  reply	other threads:[~1999-07-14 16:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-12 17:20 Undecidability of OCaml type checking Andreas Rossberg
1999-07-13 17:59 ` irritability of structure name conflicts Dave Mason
1999-07-14  3:04   ` John Skaller [this message]
1999-07-14 15:43   ` Xavier Leroy
1999-07-14 15:32 ` Undecidability of OCaml type checking Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3.0.6.32.19990714130436.00987970@mail.triode.net.au \
    --to=skaller@maxtal.com.au \
    --cc=caml-list@inria.fr \
    --cc=dmason@sarg.Ryerson.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).