caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Fernando Alegre <fernando@cc.gatech.edu>
To: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
Cc: vrotaru@seznam.cz, caml-list@inria.fr
Subject: Re: [Caml-list] subtyping, polymorphism, higher order types.....
Date: Sat, 5 Jul 2003 03:46:48 -0400	[thread overview]
Message-ID: <20030705074648.GA28213@gaia.cc.gatech.edu> (raw)
In-Reply-To: <20030705112126Q.garrigue@kurims.kyoto-u.ac.jp>

On Sat, Jul 05, 2003 at 11:21:26AM +0900, Jacques Garrigue wrote:

> This looks very much like an ocaml object type to me...
> Is the absence of labels for fields important?
> 
> Note that you can also encode the above with polymorphism:
> 
>   type 'a point = int * int * 'a
>   type 'a color_point = (int * 'a) point
> 
> The only trouble here is that there is no way to create heterogeneous
> collections, since you cannot coerce a [unit color_point] to a [unit
> point]. Actually, this just comes from a missing relation in the ocaml
> type algebra: the type Obj.t is not recognized as a supertype for all
> types. If this were the case then you would be able to write:
>   let l = [ (p :> Obj.t point); (cp :> Obj.t point) ]
> 
> That would be easy enough to add, but is it that useful?

I think yes. That would allow us to avoid creating ad-hoc classes whose only
use is such heterogeneous storage. This would save quite a few lines of
wrapping code when the basic data structure is a record or a sum type that
is extended with a problem-specific type.

Currently, the problem is not just heterogeneous collections. In our program,
a mutable variable of type 'a model can not be reused to solve one model
after another without exiting the program and restarting with a different
model, unless we wrap everything in classes. Exiting the program is really
inconvenient for interactive user interfaces, and wrapping the code adds
many unnecessary lines. So, something like Obj.t coercion would be really
useful. 

Fernando

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-07-05  7:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-03 14:33 Shaddin Doghmi
2003-07-03 16:23 ` brogoff
2003-07-04  6:43 ` Daniel Weil
2003-07-04 20:45 ` Vasile Rotaru
2003-07-05  2:21   ` Jacques Garrigue
2003-07-05  7:46     ` Fernando Alegre [this message]
2003-07-05 15:07     ` Vasile Rotaru

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=20030705074648.GA28213@gaia.cc.gatech.edu \
    --to=fernando@cc.gatech.edu \
    --cc=caml-list@inria.fr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    --cc=vrotaru@seznam.cz \
    /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).