caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Andreas Rossberg <AndreasRossberg@web.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Instruction selection in the OCaml compiler: Modulesor classes?
Date: Sat, 24 Feb 2007 13:51:28 +1100	[thread overview]
Message-ID: <1172285488.23720.53.camel@rosella.wigram> (raw)
In-Reply-To: <007401c75780$c87c53d0$15b2a8c0@wiko>

On Fri, 2007-02-23 at 20:28 +0100, Andreas Rossberg wrote:
> Tom <tom.primozic@gmail.com> wrote:
> >
> > I think you should take a look at another currently active thread  -
> > "Feature request : Tuples vs. records". One of the red lines there is the
> > comparison of structural versus nominal typing - classes and objects
> > belonging to the former, and modules and records to the latter.
> 
> Not exactly: ML modules employ fully structural typing and subtyping. That 
> is their big strength, in contrast to comparable features in most other 
> languages (particularly typical notions of class).

I wonder if more explanation could be given here? I admit continuing
to be confused by the status of modules.

It seems like a module functor allows both anonymous 
signatures (structural) and also anonymous argument 
modules (structural), yet you cannot have
anonymous functor applications: you have to bind the application to
a module name. If we really had structural typing that name would
simply be an alias. Why can't we eliminate that name? ***

C++ template applications can be anonymous, and that gives them
a major edge over Ocaml modules. Similarly, when you're lucky
enough to be able to use non-modular functor (a function with
polymorphic type) it is much more convenient. For example Hashtbl
provides both alternatives, whereas Set and Map do not (a fact
many people complain about).

*** more precisely, we probably don't want to eliminate the name
most of the time, but we would like to be able to use a 
'Set of int' in several modules without having to *export* 
the type in another module so it can be reused.

This is particularly annoying when it is intractable: for
example I have variant terms some of which contain sets
of terms .. the recursion is easy to represent with
lists but you can't do it with modular data structures.
The way I do it is make sets of integers instead and 
keep a term table indexed by the integers. But this isn't
really safe. There's probably a better way but the fact
remains if I want the type safety I have to use lists
or some other non-modular data structure: the modules
actually get in the way of type safety instead of 
enhancing it. I guess the 'recursive modules' stuff will
help fix this?


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-02-24  2:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-22 14:38 Instruction selection in the OCaml compiler: Modules or classes? Joel Reymont
2007-02-22 17:21 ` [Caml-list] " Tom
2007-02-22 17:38 ` Xavier Leroy
2007-02-22 19:55 ` Chris King
2007-02-22 19:59 ` Markus Mottl
2007-02-23 16:13 ` brogoff
2007-02-23 18:14   ` Tom
2007-02-23 19:28     ` [Caml-list] Instruction selection in the OCaml compiler: Modulesor classes? Andreas Rossberg
2007-02-24  2:51       ` skaller [this message]
2007-02-24 11:48         ` David Baelde
     [not found]           ` <4a708d20702240518l2c430b06r18fe64cabe5cbe9@mail.gmail.com>
2007-02-24 13:33             ` Lukasz Stafiniak
2007-02-24 14:58         ` [Caml-list] Instruction selection in the OCaml compiler:Modulesor classes? Andreas Rossberg
2007-02-24 17:39           ` skaller

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=1172285488.23720.53.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=AndreasRossberg@web.de \
    --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).