From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D251CBCAE for ; Sun, 26 Jun 2005 13:07:36 +0200 (CEST) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j5QB7aWi009191 for ; Sun, 26 Jun 2005 13:07:36 +0200 Received: by rproxy.gmail.com with SMTP id a36so724388rnf for ; Sun, 26 Jun 2005 04:07:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Xt2MQQMCBtnbgerwUm4H7Qwb5v2vuL51dam1Koivdk7T4YOqu0SrQv3cVm6pZ+HGoQc32byfBeQUasGj2UPLbpZEO1wzDuMmPcon1RGGXBO1abIV4zpkrTZ+v3BVOWnFv+82+HPKG7TEgfyNmjwOCUVf1eVVzijooXk72LDf+as= Received: by 10.38.65.49 with SMTP id n49mr2134837rna; Sun, 26 Jun 2005 04:07:35 -0700 (PDT) Received: by 10.38.209.44 with HTTP; Sun, 26 Jun 2005 04:07:35 -0700 (PDT) Message-ID: Date: Sun, 26 Jun 2005 23:07:35 +1200 From: Jonathan Roewen Reply-To: Jonathan Roewen To: caml-list@yquem.inria.fr Subject: [Caml-list] Making something similar to format[4] Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at nez-perce with ID 42BE8C78.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printf:01 scanf:01 bigarray:01 struct:01 bool:01 char:01 specifier:01 char:01 c-like:01 structs:01 type-safe:01 ocaml:01 parser:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: Hi, 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 =3D bool, <=3D 8 char/int (format specifier to choose char), <=3D 31 int/int32, =3D 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 stage. Jonathan