caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: caml-list@inria.fr
Subject: A proposal for overloading ...
Date: Thu, 28 Dec 2000 15:19:13 -0500	[thread overview]
Message-ID: <3A4BA041.F878C6BE@univ-savoie.fr> (raw)
In-Reply-To: <4.3.2.7.2.20001226151428.00b2f680@shell16.ba.best.com>


What follows is a proposal to add overloading to ocaml with the
following properties:

- compatibility of existing code
- simple to implement and understand (it is my opinion)
- not limited to arythmetic operation

The implementation is in two steps:

When parsing an identifier search the list of all value in the
environment having the same name. So at parsing time, the value of an
identifier is a list of Ocaml term. 

At type checking, when type-checking the type of an identifier two cases
occur:
1) there is only one possible value in the list whose type unify with
the required type: in this case we known the real value of the
identifier. (note: in ML type checking implementation, each value in the
environment as a type assigned so we just need to try to unify the
required type with all possible type)
2) there are more than one value whose type unify with the required
type:
in this case we delay the typing-checking of that identifier

* At the end we have a set of identifier whose type checking have been
delayed. It is possible that some identifiers know have only one
possible value (because we got extra typing information). We enter a
loop  until all identifiers have an ambiguous value or all identifier
have been type checked.

Then, if there is still some identifiers with ambiguous value, we choose
one (the first by position in the source code ?), and assign it the
first possible value in the list (this choice insure compatibility with
existing code). This may add extra typing information, so we go back to
step *. It would be good to issue a warning in this case because it may
help detect bugs in the following situation:

let i = ... in
...
let i = ... in
...
i 
...

where both i have the same type and the reference to i reffers to the
first one in the mind of the programmer that did not see the second one.

What do the implementors and users of Ocaml think of this ?
Is it compatible with the complex feature in Ocaml typing  (like
functor, object, type-checking of let rec ..) ?
 
-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI



  parent reply	other threads:[~2000-12-30 21:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-26 23:47 status of some big "important" features? Chris Hecker
2000-12-28  9:10 ` Daniel de Rauglaudre
2000-12-30 19:30   ` Chris Hecker
2000-12-30 20:53     ` Daniel de Rauglaudre
2000-12-31  1:58       ` Chris Hecker
2000-12-31  3:08         ` Daniel de Rauglaudre
2001-01-02 17:39           ` William Chesters
2000-12-31 20:39   ` John Max Skaller
2000-12-28 20:19 ` Christophe Raffalli [this message]
2001-01-02 10:38   ` A proposal for overloading Didier Remy
2001-01-02 19:08     ` Christophe Raffalli

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=3A4BA041.F878C6BE@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    /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).