From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA19264; Thu, 31 May 2001 22:34:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA19277 for ; Thu, 31 May 2001 22:34:25 +0200 (MET DST) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f4VKYJb00035 for ; Thu, 31 May 2001 22:34:20 +0200 (MET DST) Received: (qmail 4683 invoked from network); 31 May 2001 20:34:05 -0000 Received: from unknown (HELO w2kpro) ([64.81.246.34]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 31 May 2001 20:34:05 -0000 Message-ID: <00c301c0ea11$17a38570$22f65140@w2kpro> From: "Harry Chomsky" To: "Caml list" Subject: [Caml-list] Win32 API Date: Thu, 31 May 2001 13:34:29 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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