caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jim Farrand" <jim.farrand@gmail.com>
To: "Caml Mailing List" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] The Bridge Pattern in OCaml
Date: Fri, 28 Mar 2008 10:44:41 +0000	[thread overview]
Message-ID: <e16c7bcd0803280344r1a26353w57884e5078582961@mail.gmail.com> (raw)
In-Reply-To: <891bd3390803191907q5838ee66u83cb35e549805af0@mail.gmail.com>

On 20/03/2008, Yaron Minsky <yminsky@gmail.com> wrote:

> For what it's worth, not at Jane Street.  We've looked at using existential
> types once or twice, but have yet to find a really compelling application.
> We don't really use objects much either.
>
> I'm actually a bit puzzled by your original post, in that I don't have a
> clear sense of what kind of situations you've run up against where using
> poor-man's objects (e.g., collections of closures wrapped up in a bundle)
> doesn't do the job.  On the whole, I've found that collections of closures
> are easier to think about than objects precisely because you don't have to
> worry about subtyping.  I'd be quite curious to hear about concrete examples
> where that approach doesn't fit well.

Hi,

Apologies for chipping in so late.

I've used the "poor man's objects" approach quite often.  It's very
powerful and nicely modular - especially when creating frameworks
intended to be used by other programmers.  You can provide a module
which dictates an interface, while allowing clients of the module to
provide the precise implementation.

However, I always find it unravels quite quickly when a requirement is
added to store state on disk or send it over the network.  Records
containing closures aren't suitable for this.  I can use the O'Caml
marshalling system, but I don't really understand how this is useful
in practice, because data isn't portable between different
compilations of the program

To give a concrete, but slightly simple example (which I've hit in the
real world): you are writing a game writing framework.  You want to
allow client code to implement different kinds of Monster behaviour by
providing a function (game_state -> monster_state -> action).  The
complete game and monster state needs to be saved and reloaded,
possibly between different versions of the program.

Do any O'Caml design gurus have opinions on how best to do this?  I've
never been satisfied with any of the solutions I've come up with.

Regards,
Jim


  parent reply	other threads:[~2008-03-28 10:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-19 16:29 Christopher L Conway
2008-03-19 16:51 ` [Caml-list] " Bünzli Daniel
2008-03-19 17:44   ` Christopher L Conway
2008-03-19 18:06     ` Christopher L Conway
2008-03-20  2:07       ` Yaron Minsky
2008-03-20 13:27         ` Martin Jambon
2008-03-20 20:10           ` Christophe Raffalli
2008-03-28 10:44         ` Jim Farrand [this message]
2008-03-28 11:06           ` Michael Wohlwend
2008-03-28 11:29             ` Jim Farrand
2008-03-28 11:57               ` Oliver Bandel
2008-03-28 11:30             ` Oliver Bandel
2008-03-28 11:45               ` Jim Farrand
2008-03-28 11:52                 ` Michael Wohlwend
2008-03-28 12:09                   ` Oliver Bandel
2008-03-28 12:43                     ` Jim Farrand
2008-03-28 18:23                       ` Raoul Duke
2008-03-28 18:29                         ` Robert Fischer
2008-03-28 18:34                         ` David Thomas
2008-03-28 19:14                           ` blue storm
2008-03-28 19:04                         ` Oliver Bandel
2008-03-28 19:05                         ` Mathias Kende
2008-03-28 19:47                         ` Jon Harrop
2008-03-28 23:24                           ` Oliver Bandel
2008-03-31  8:31                         ` Berke Durak
2008-03-29 14:03                       ` Peng Zang
2008-03-28 12:03                 ` Oliver Bandel

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=e16c7bcd0803280344r1a26353w57884e5078582961@mail.gmail.com \
    --to=jim.farrand@gmail.com \
    --cc=caml-list@yquem.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).