caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Why can't immediate objects be extended?
Date: Sat, 12 Jul 2008 15:26:47 +0100	[thread overview]
Message-ID: <20080712142647.GA9917@annexia.org> (raw)
In-Reply-To: <20080712141200.GA8634@annexia.org>

On Sat, Jul 12, 2008 at 03:12:00PM +0100, Richard Jones wrote:
>         let obj = object
>   	  inherit (typeof parent_obj)
>   	  method str = string_of_tree t
>         end in
>         Node (annotate left, obj, annotate right)

Further exploration reveals I can write this, which is _almost_ what I
want:

  let obj = object
    inherit object method parent = parent_obj end
    method str = string_of_tree t
   end in ...

except the indirection through a parent method is not helpful for what
I'm trying to achieve (an extensible static type that doesn't depend
on the order in which the type is extended).

The types produced by this are:

  val annotate : 'a tree -> < parent : 'a; str : string > tree = <fun>

  val tree : < parent : <  >; str : string > tree = (* ... *)

Rich.

-- 
Richard Jones
Red Hat


  reply	other threads:[~2008-07-12 14:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-12 14:12 Richard Jones
2008-07-12 14:26 ` Richard Jones [this message]
2008-07-14  1:47 ` [Caml-list] " Peng Zang
2008-07-14 14:38 ` Keiko Nakata
2008-07-16  1:43 ` 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=20080712142647.GA9917@annexia.org \
    --to=rich@annexia.org \
    --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).