Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <Basile.Starynkevitch@cea.fr>
To: caml-list@pauillac.inria.fr
Subject: mixed customizable external data types in Caml
Date: Thu, 4 Dec 1997 09:28:33 +0100	[thread overview]
Message-ID: <199712040828.JAA20050@vega.serma.cea.fr> (raw)


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






             reply	other threads:[~1997-12-04 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-12-04  8:28 Basile STARYNKEVITCH [this message]
1997-12-07 13:41 Damien Doligez

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=199712040828.JAA20050@vega.serma.cea.fr \
    --to=basile.starynkevitch@cea.fr \
    --cc=caml-list@pauillac.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