From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA09718 for caml-redistribution; Thu, 4 Dec 1997 17:05:05 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA01651 for ; Thu, 4 Dec 1997 09:29:05 +0100 (MET) Received: from nenuphar.saclay.cea.fr (nenuphar.saclay.cea.fr [132.166.192.7]) by concorde.inria.fr (8.8.7/8.8.5) with ESMTP id JAA18621 for ; Thu, 4 Dec 1997 09:29:05 +0100 (MET) Received: from vega.serma.cea.fr (vega.serma.cea.fr [132.166.149.56]) by nenuphar.saclay.cea.fr (8.8.5/CEAnet-relay-4.0.3) with ESMTP id JAA18505 for ; Thu, 4 Dec 1997 09:29:04 +0100 (MET) Received: (from basile@localhost) by vega.serma.cea.fr (8.8.6/8.8.5) id JAA20050; Thu, 4 Dec 1997 09:28:33 +0100 Date: Thu, 4 Dec 1997 09:28:33 +0100 Message-Id: <199712040828.JAA20050@vega.serma.cea.fr> From: Basile STARYNKEVITCH MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: caml-list@pauillac.inria.fr Subject: mixed customizable external data types in Caml X-Mailer: VM 6.34 under 20.3 "Vatican City" XEmacs Lucid Sender: weis [[English]] When using caml as an embedding langage (concretly, caml used as a scripting langage to existing numerical applications coded in Fortran or C) it would be very nice to be able to have a Caml value containing both Caml values (ie pointers or tagged integers) and other stuff, such (as a Fortran matrix or whatever). Of course it is already possible to use an arbitrary pointer to whatever C or Fortran data. But it would be nice to be able to have all of Caml memory management stuff (in particular garbage collection and marshalling) in mixed data types. I would wish that a special Mixed_tag exists, and that mixed data would have the following C structure struct mixed_data_st { unsigned caml_header; struct mixed_descriptor_st *descr; unsigned data[0] /* the actual data */; } where the descriptor is a structure like struct mixed_descriptor_st { unsigned descriptor_magic; /* a constant magic */ char *type_name; /* finalizing routine */ void (*finalizer_func) (struct mixed_data_st*data); /* scanning references routine */ void (*refscan_func) (struct mixed_data_st *data, void(*scan_func)(value*,void*), void *clientdata); /* moving routine */ void (*mover_func) (struct mixed_data_st *dest, struct mixed_data_st *src); /* marshalling routine */ void (*marshall_func) (struct mixed_data_st* dest, char* data, int datalen); /* unmarshalling routine - return the needed byte length */ int (*unmarshall_func) (struct mixed_data_st* dest, char* data, int datalen); /* etc ... */ }; So the descriptor contains routine to finalisz, scan the reference fields (for the GC), move or copy (for the copying GC), marshall & unmarshall; etc... I know that from a Caml-centric point of view external data containing Caml references is a useless nuisance. But I think that it would promote Caml usage in existing (legacy) applications. From my reading of the runtime system code, I think that adding it would be rather easy for the runtime system coder (essentially, it only deals with hooks). [[ Résumé français ]] Il me semble que pour faciliter l'utilisation de Caml comme interprète embarqué dans des applications existantes, il serait souhaitable de disposer de type (au runtime) mélangeant référence Caml et valeurs autres. Une façon possible de ce faire serait d'avoir une étiquette Mixed_tag avec des données contenant un descripteur. Celui-ci serait une structure C contenant les routines appropriées pour le ramasse-miettes, la finalisation, le codage/décodage, etc... N.B. Any opinions expressed here are solely mine, and not of my organization. N.B. Les opinions exprimees ici me sont personnelles et n engagent pas le CEA. ---------------------------------------------------------------------- Basile STARYNKEVITCH ---- Commissariat à l Energie Atomique DRN/DMT/SERMA * CEA/Saclay bat.470 * 91191 GIF/YVETTE CEDEX * France fax: (33) 01,69.08.85.68; phone: 01,69.08.40.66; home: 01,46.65.45.53 email: Basile . Starynkevitch @ cea . fr (but remove white space) I speak french, english, russian. Je parle français, anglais, russe. ----------------------------------------------------------------------