caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: skaller <skaller@users.sourceforge.net>
Cc: caml-list@yquem.inria.fr, Richard Jones <rich@annexia.org>
Subject: Re: [Caml-list] Polymorphic method question
Date: Mon, 10 Jul 2006 21:56:52 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0607102143020.26509@shell2.speakeasy.net> (raw)
In-Reply-To: <1152584645.5206.46.camel@rosella.wigram>

On Tue, 11 Jul 2006, skaller wrote:

> On Mon, 2006-07-10 at 16:25 -0700, brogoff wrote:
>
> > The restriction on polymorphism in mutually recursive class
> > definitions makes the idea unworkable. Any possibility that restriction will be
> > lifted?
>
> I don't believe there is such a restriction:

See the thread that Richard referenced, and go to Jacques Garrigue's final post.
There he writes:

    "Inside mutually recursive definitions of classes, parameters cannot be
    used polymorphically"

That's the problem, isn't it?

> the problem is
> when you introduce other types such as variants which must
> recurse with class types, there's no support for
>
> type class t1 = ..
> and t2 = [`X ..]

That's surely annoying, but it's a different problem I think.
>
> etc. The solution, using extra parameters and open
> recursion, followed by closure of the recursions,
> works but is vastly too messy to encode by hand if there
> are more than a couple of parameters needed. This really
> does need to be automated in the special case where
> you're only opening the types so you can later close them.

If you look at the faux OCaml code I provided, I believe the intent
is clear, forgiving OCaml's, ummm, suboptimal syntax. I could code
it up in Java 1.5 (maybe I should, just to make sure it works!) and
since Java doesn't do parameter inference it may all work fine.

> In general, for incremental type building, you need to retain
> the open types.. and it isn't clear if there's any way
> to make it tractable (syntactically I mean).

The code for this in Java 1.5 is quite clear, syntactically. It's a bit
tricky to get it all right, of course, but someone smarter than me already
figured it out, I just want to implement the trick in my language of
choice, which is not Java.

> Unfortunately .. the easiest kind of solution is to write
> a code generator in Python or Perl .. this kind of polymorphism
> is not exactly desirable .. ;(

No, I think you're missing the point of the "exercise" here. I'm not looking for
a code generator, but an OO approach to building extensible visitors with
precise static type checking.

-- Brian


  reply	other threads:[~2006-07-11  4:56 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 [this message]
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
  -- 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.0607102143020.26509@shell2.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=rich@annexia.org \
    --cc=skaller@users.sourceforge.net \
    /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).