caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: Damien.Pous@ens-lyon.fr
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] functors and objects
Date: Fri, 06 Feb 2004 10:30:13 +0900	[thread overview]
Message-ID: <20040206103013B.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <20040205144506.57a47fc7.Damien.Pous@ens-lyon.fr>

From: Damien <Damien.Pous@ens-lyon.fr>
> On Thu, 05 Feb 2004 18:18:45 +0900 Jacques Garrigue wrote:
> 
> > Because instanciation/specialization only works for values, not for
> > types.
> > This is reasonable enough: once you have defined a type, you may use
> > it both in covariant and contravariant positions, so allowing to
> > specialize it would be unsound.
> > (So, yes, in the long run this is a soundness problem.)
> 
> I don't see the point :-(
> 
> module type O = 
> sig
> 	type " t :> o "
> end
> 
> can be read as
> 
> module type O =
> sig
> 	type ellipsis (* abstract *)
> 	type t = " <o; ellipsis> "
> end
> 
> therefore, a functor F(M: O) cannot create objects of type t without the
> help of M. 

I see.
This way you can coerce from t to o, but not the other way round.
The trouble is just that in ocaml, the row variable of an object type
is not a type in itself (even if it uses the same datatype
representation in the compiler).
There are actually three possible row-endings:
  Tvar -> an extensible row, as the one in "#o"
  Tnil -> a closed row, as in "o"
  Tunivar -> an existential row variable, unifies only with itself,
          and must be bound locally. used for polymorphic variables in
          polymorphic methods.
What you are asking for is actually adding a 4th form,
  Tconstr (path, args, memo) ->
      extension through a type (abstract or concrete) 
Not only would this require to extend all existing handling of
row-endings (which occur in many places in the compiler), but this
should also include the possibility that the extension is concrete
(needed as you want to be able to add methods through functor
application), and should be expanded when looking for a method. This
breaks another assumption in the compiler (that no expansion is needed
to access the method types.)

But all this technical part is possible.
The real question is: would it be useful?
Note that compared to a class-based approach, the extensibility would
still be weaker: in declaration
   type ('a1,..,'an) t :> ('a1,..,'an) o
only the type variables 'a1 to 'an can be used in extra methods.
This is a well-known problem with functors, but would be even more
problematic if we allow this kind of semi-abstract types.

For all these reasons, your idea, while theoretically interesting,
does not attract me so much: lots of work for a rather weak result,
while there are already simpler ways to do the same thing.

Jacques Garrigue

-------------------
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:[~2004-02-06  1:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-03 18:06 Damien
2004-02-03 19:37 ` Matt Gushee
2004-02-03 19:39 ` [Caml-list] functors and objects' Matt Gushee
2004-02-03 20:26   ` Damien Pous
2004-02-04  2:57 ` [Caml-list] functors and objects Jacques Garrigue
2004-02-05  8:55   ` Damien
2004-02-05  9:18     ` Jacques Garrigue
2004-02-05 13:45       ` Damien
2004-02-06  1:30         ` Jacques Garrigue [this message]

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=20040206103013B.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=Damien.Pous@ens-lyon.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).