Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: peng.zang@gmail.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] on polymorphic compare and objects
Date: Wed, 03 Sep 2008 08:31:10 +0200	[thread overview]
Message-ID: <48BE2F2E.5020805@frisch.fr> (raw)
In-Reply-To: <200809021909.35930.peng.zang@gmail.com>

Peng Zang wrote:
> For objects, we require that all objects
> implement an equal method that satisfies the semantic contract.

How do you ensure that the method is indeed implemented and has the 
correct type?

A more robust approach to attaching custom generic operations to 
arbitrary data would be to introduce the equivalent of custom blocks, 
but for OCaml data. This probably amounts to reserving a new GC tag and 
deciding on a memory layout (e.g. a block with this tag has two fields: 
the underlying value and a dictionary of generic functions). Then simple 
modules in stdlib could expose a well-typed interface (ensuring that the 
type of the dictionary's functions is compatible with the type of the 
underlying values). It would even be possible to expose the resulting 
blocks as values of a private record type with two fields, so as to 
preserve pattern matching on the underlying value.


   Alain


  reply	other threads:[~2008-09-03  6:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-02 23:09 Peng Zang
2008-09-03  6:31 ` Alain Frisch [this message]
2008-09-03 14:38   ` [Caml-list] " Peng Zang

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=48BE2F2E.5020805@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=peng.zang@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