caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Harry Chomsky" <harry@chomsky.net>
To: "Caml list" <caml-list@inria.fr>
Subject: [Caml-list] Win32 API
Date: Thu, 31 May 2001 13:34:29 -0700	[thread overview]
Message-ID: <00c301c0ea11$17a38570$22f65140@w2kpro> (raw)

I've embarked on a project to enable writing full-fledged Win32 applications
using OCaml.  I'm doing this mostly for fun as I take a break between jobs.
Of course I hope some people may find it useful in the end.  There's a long
way to go still, but I wanted to let the community know that I'm doing this
and see if you have any advice.  Most of all, if this has already been done,
please tell me so I can stop wasting my time!  As far as I can tell from the
mailing list archives, it has not been done yet, and a few people have
requested it.

If anyone wants to see where I am with it, and offer help or feedback, I've
posted the code at:

http://www.speakeasy.org/~hchomsky/ocaml-win32.html

Much of the work is tedious, but it's been interesting trying to compensate
for Win32's tendency to use C's weak typing.  I've tried to present the API
to OCaml programmers in a strongly typed fashion consistent with the OCaml
philosophy, but still provide all the capabilities that Win32 C programmers
are used to.

The main area I'm uncomfortable with is memory management and the section of
the OCaml manual entitled "Living in harmony with the garbage collector".  I
can't tell from the manual whether I need to pay attention to all these
rules and special C macros.  I do use the C functions malloc and free
occasionally, but only in a very local fashion -- I never pass the resulting
pointers back to the OCaml program.  My C code also makes extensive use of
the functions alloc, alloc_tuple, copy_string, etc. and the macros
Store_field, etc. that are provided by the OCaml runtime library.  So far
everything "just works", but I'd like to make sure I'm not overlooking some
kind of lurking problem here.  Can someone give me a clear explanation of
when I can safely ignore rules 1 and 2?

One place where I most likely *do* have a problem is the array of "message
handler" functions that the C code stores when it registers a window class.
I think I have to register these as global roots, since in theory the OCaml
code could provide dynamically-generated closures which are at risk of being
garbage-collected.  Again, my understanding is fuzzy and I would appreciate
any advice.

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


             reply	other threads:[~2001-05-31 20:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-31 20:34 Harry Chomsky [this message]
2001-05-31 22:13 ` Daniel de Rauglaudre
2001-05-31 22:59   ` Harry Chomsky
2001-06-01 11:48     ` Daniel de Rauglaudre
2001-06-04  4:01       ` Harry Chomsky
2001-06-04  4:49         ` Daniel de Rauglaudre
2001-06-04  8:53           ` Stefan Monnier
2001-06-02 14:56 ` Dmitry Bely
2001-12-31 20:52 Harry Chomsky
2002-01-01 18:22 ` Warp
2002-01-02  4:56   ` Harry Chomsky
2002-01-02 20:27     ` Warp
2002-01-12 21:37 ` Harry Chomsky

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='00c301c0ea11$17a38570$22f65140@w2kpro' \
    --to=harry@chomsky.net \
    --cc=caml-list@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).