Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Prevost <prevost@zarya.maya.com>
To: Jerome Vouillon <Jerome.Vouillon@inria.fr>
Cc: Hendrik Tews <tews@tcs.inf.tu-dresden.de>, caml-list@inria.fr
Subject: Re: grammar for class types, reraised
Date: 15 Jun 1999 13:04:17 -0400	[thread overview]
Message-ID: <ya2g13ttmy6.fsf@zarya.maya.com> (raw)
In-Reply-To: Jerome Vouillon's message of "Mon, 14 Jun 1999 23:30:19 +0200"

Jerome Vouillon <Jerome.Vouillon@inria.fr> writes:

> This would probably be possible, but it is not trivial. And then, you
> would probably expect to be able to include in the recursion other
> construct, such as value definitions (for instance, if a function
> using the type b is used by the class a). This would make the
> implementation even more complicated.
> 
> On the other hand, you can get rid of the mutual recursion by adding a
> type parameter to one of the type. For instance, you can change
>     class type a = object method m : b end
>     and
>     type b = Node of a | Tree of b * b
> into
>     type 'a b = Node of 'a | Tree of b * b
>     class type a = object method m : a b end

My situation was somewhat more obscene, and would've required this:

type ('foo,'bar,'baz,'qux,'blatz,'zuttle,'potz,...) cast =
 | Foo of 'foo
 | Bar of 'bar
 | ...

class type node = object method downcast : (foo,bar,...) cast end
and bar = object ... end
...

The whole point of the excercise was to have a downcast method for a
set of specific classes, in a type-safe way.  I eventually wrote code
using < ... > for all of the types.

John.




  reply	other threads:[~1999-06-15 20:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-14  8:04 Hendrik Tews
1999-06-14 21:30 ` Jerome Vouillon
1999-06-15 17:04   ` John Prevost [this message]
1999-06-22 17:00   ` Hendrik Tews
1999-06-23  1:40     ` 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=ya2g13ttmy6.fsf@zarya.maya.com \
    --to=prevost@zarya.maya.com \
    --cc=Jerome.Vouillon@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=tews@tcs.inf.tu-dresden.de \
    /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