Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: caml-list@yquem.inria.fr, Nicolas Ojeda Bar <nojb@math.harvard.edu>
Subject: Re: [Caml-list] obj magic performance and other questions
Date: Tue, 15 Mar 2011 10:17:03 -0700 (PDT)	[thread overview]
Message-ID: <344974.14932.qm@web111506.mail.gq1.yahoo.com> (raw)
In-Reply-To: <057400AC-9E39-45CC-AB7A-35C67C339F83@math.harvard.edu>

Hi,

> I need to simulate, in Ocaml, the extensible records of
> Oberon. I am doing the
> following:
> 
> Oberon type declaration:
> 
> TYPE
> 
> rec1 = RECORD a : INTEGER END;
> rec2 = RECORD (rec1) b : CHAR END;
> rec3 = RECORD (rec1) c : REAL END;

Have you considered leveraging the structural subtyping features of the object system, or do you reckon the (small) performance penalty is too
great?

type rec1 = < a: int >
type rec2 = < a: int; b: char >
type rec3 = < a: int; c: float >

let make_rec1 a =
object
  method a = a
end

let make_rec2 a b =
object
  method a = a
  method b = b
end

...and so forth.

Best regards,
Dario Teixeira



      


  reply	other threads:[~2011-03-15 17:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-15 16:05 Nicolas Ojeda Bar
2011-03-15 17:17 ` Dario Teixeira [this message]
2011-03-16  2:21 ` Guillaume Yziquel
     [not found] ` <325023989.96091.1300242147328.JavaMail.root@zmbs4.inria.fr>
2011-03-16  8:46   ` Fabrice Le Fessant
2011-03-17 16:36 ` Damien Doligez

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=344974.14932.qm@web111506.mail.gq1.yahoo.com \
    --to=darioteixeira@yahoo.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=nojb@math.harvard.edu \
    /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