caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Polymorphic method question
Date: Wed, 12 Jul 2006 12:26:21 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0607121134490.8222@shell2.speakeasy.net> (raw)
In-Reply-To: <20060712.093717.16034933.garrigue@math.nagoya-u.ac.jp>

On Wed, 12 Jul 2006, Jacques Garrigue wrote:
> From: brogoff <brogoff@speakeasy.net>
> > > I'm sure you need some tricks to make it work in Java 1.5 too.
> >
> > The nastiest one for Caml is a downcast, when you want to extend the data
> > the new class must call the extended visitor in its visit method. But Java
> > supports this, so no big deal.
>
> Well, if you're ready to have downcasts in your code...
> But then,

I'd hoped that there would be some trick I could figure out to remove the
downcast, but it's essentially to overcome the lack of covariant
method arguments (the visitor argument of the visited class) so yes it's a
flaw in the approach.

> I would not say that your Java version is more "typed". It is less so
> if you have downcasts!

Fair enough. However, the "typecase" that's being performed has only one branch,
and is localized to the extending class, so as such crimes go, it's more
like vandalism than arson.

> [About having to write the type hierarchy by hand]
> > But we have to repeat the information from the type in a later class,
> > which seems redundant. Also, there's no way I know of to build object types
> > from other object types, similar to the way I can combine polymorphic variant
> > types.
> >
> > I haven't tried to encode it yet, maybe I'll try later, but I don't
> > see how it can be made to work.
>
> Indeed. At times I wonder whether it would not be better to have a
> syntax to do this with types. Or maybe not to infer parameter
> constraints for class types, as they are required for extensibility.

I think if we're going to do OO in an ML like language, I think it is probably
more promising to consider a system like Dylan or CLOS. But that's a huge
change, for a brand new language.

I'd rather have a simpler language, with more powerful records, variants and
module system. I usually use classes in OCaml as records anyways.

-- Brian


  reply	other threads:[~2006-07-12 19:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-10 19:21 brogoff
2006-07-10 20:05 ` [Caml-list] " Richard Jones
2006-07-10 23:25   ` brogoff
2006-07-11  2:24     ` skaller
2006-07-11  4:56       ` brogoff
2006-07-11  2:09 ` Jacques Garrigue
2006-07-11  5:22   ` brogoff
2006-07-11  7:32     ` Jacques Garrigue
2006-07-11 18:20       ` brogoff
2006-07-12  0:37         ` Jacques Garrigue
2006-07-12 19:26           ` brogoff [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-08-21 21:49 [Caml-list] polymorphic " nadji
2002-08-21 22:57 ` Jacques Garrigue

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=Pine.LNX.4.58.0607121134490.8222@shell2.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).