caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Win32 API
@ 2001-05-31 20:34 Harry Chomsky
  2001-05-31 22:13 ` Daniel de Rauglaudre
  2001-06-02 14:56 ` Dmitry Bely
  0 siblings, 2 replies; 13+ messages in thread
From: Harry Chomsky @ 2001-05-31 20:34 UTC (permalink / raw)
  To: Caml list

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


^ permalink raw reply	[flat|nested] 13+ messages in thread
* [Caml-list] Win32 API
@ 2001-12-31 20:52 Harry Chomsky
  2002-01-01 18:22 ` Warp
  2002-01-12 21:37 ` Harry Chomsky
  0 siblings, 2 replies; 13+ messages in thread
From: Harry Chomsky @ 2001-12-31 20:52 UTC (permalink / raw)
  To: Caml-list

For several months I've been putting together an OCaml library providing
direct access to the Win32 API.  It's a huge project that I'm sure I will
never totally finish... but I've got a good chunk of it done, and I've just
posted it at the following URL:

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

It requires OCaml 3.04, because it uses the module include feature in
combination with "external" declarations.

If anybody has questions or comments about this code or would like to use
it, please let me know.  I'm planning to use it in the near future to build
a tool for interactive OCaml programming, similar to an IDE in some ways.

Last time I posted this, in May, I had some concerns about memory
management.  The discussion that followed convinced me that I was doing it
wrong, and I fixed the problems according to my new understanding.  I'm
pretty sure I've gotten it right this time.

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-01-12 21:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-31 20:34 [Caml-list] Win32 API Harry Chomsky
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

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).