caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Gerd Stolpmann <info@gerd-stolpmann.de>, Jordan W <jordojw@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Object Features
Date: Mon, 01 Dec 2014 11:09:13 +0100	[thread overview]
Message-ID: <547C3E49.7030809@frisch.fr> (raw)
In-Reply-To: <1417362565.6436.88.camel@e130.lan.sumadev.de>

On 11/30/2014 04:49 PM, Gerd Stolpmann wrote:
> What could in deed be useful is a more light-weight construction that
> layers objects, i.e. you define a new object around an existing one:

Indeed, being able to define an object by extending an existing one 
would be quite useful (perhaps overriding some methods, being understood 
that this doesn't affect late-bound calls from that object to itself).

I'd rather see that as a new kind of class expressions, say "of object 
<expr>", where <expr> could be an object expression (with a fixed type)
so that you could write:

  let new_object old_object =
    object
      inherit of object (old_object : t)

      method foo = ...

      method! bar = ...
    end

This would also allow to merge two existing objects into one.

If <expr> has type < m1:t1; ...; mn: tn >, "of object <expr>" would be 
equivalent to

   let o = <expr> in
   object
     method m1 = o # m1
     ...
     method mn = o # mn
   end



-- Alain

  reply	other threads:[~2014-12-01 10:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30  4:24 Jordan W
2014-11-30 13:45 ` Philippe Wang
2014-12-08  9:34   ` Goswin von Brederlow
2014-12-08 10:06     ` Gabriel Scherer
2014-11-30 15:49 ` Gerd Stolpmann
2014-12-01 10:09   ` Alain Frisch [this message]
2014-12-26 23:45     ` Jordo
2014-12-01  9:49 ` Jeremy Yallop
2014-12-08  9:35   ` Goswin von Brederlow
2014-11-30 15:53 Damien Guichard

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=547C3E49.7030809@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=info@gerd-stolpmann.de \
    --cc=jordojw@gmail.com \
    /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).