caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Jonathan Roewen <jonathan.roewen@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] C++ templates to OCaml
Date: Sun, 19 Jun 2005 21:53:31 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.63.0506192151350.23479@localhost.localdomain> (raw)
In-Reply-To: <ad8cfe7e05061823535934e9c@mail.gmail.com>



On Sun, 19 Jun 2005, Jonathan Roewen wrote:

> Hi,
>
> What's the best way to imitate C++ templates in OCaml? I have some
> code that makes extensive use of templates that I want to rewrite in
> OCaml, and using record types and functions is getting messy, and a
> lot more convoluted than the C++ code.
>
> Are objects the way to go here? And if so, can someone give me a
> simple example of how this would work?

95-99% of the uses of templates are easily replaced with either universal 
types (so List<T> becomes 'a list) or with templates (see Set and Map). 
The remainder is template meta programming, for which you probably need 
pcaml, or I'd recommend rethinking the approach (template metaprogramming 
is, IMHO, one of things wrong with C++).

Brian


      parent reply	other threads:[~2005-06-20  2:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-19  6:53 Jonathan Roewen
2005-06-19 13:17 ` Jacques Carette
2005-06-19 18:05 ` padiolea
     [not found] ` <1119175572.7402.1.camel@titania>
2005-06-19 21:32   ` Jonathan Roewen
2005-06-19 22:34     ` Benjamin Geer
2005-06-20  2:53 ` Brian Hurt [this message]

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=Pine.LNX.4.63.0506192151350.23479@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=jonathan.roewen@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).