English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Making something similar to format[4]
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-26 (11:07)
From: Jonathan Roewen <jonathan.roewen@g...>
Subject: [Caml-list] Making something similar to format[4]

I'd like to create something that works like the format type for
format strings with Printf/Scanf. What I want to do is take a
one-dimensional bigarray, and a format string of all the sizes of the
fields corresponding to a struct, and return the typed results.

So sizes of 1 = bool, <= 8 char/int (format specifier to choose char),
<= 31 int/int32, = 32 int32, > 32, int64.

The idea is to make reading/writing C-like structs painless &
automated. I'm just not sure where to begin in making this type-safe
format string. Does it require modding the ocaml parser & libraries?
Cause I'm really confused how ocaml can statically parse the string
and enforce type safety without some hack in the compiler at some