From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id B9C93BC37 for ; Wed, 28 Oct 2009 23:48:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An8BAMNm6ErRVdK2kGdsb2JhbACRZIkhPwEBAQEJCQwHEwOuS4E7hkOIaAEDAwWEOgSBYQ X-IronPort-AV: E=Sophos;i="4.44,642,1249250400"; d="scan'208";a="39128426" Received: from mail-yx0-f182.google.com ([209.85.210.182]) by mail1-smtp-roc.national.inria.fr with ESMTP; 28 Oct 2009 23:48:07 +0100 Received: by yxe12 with SMTP id 12so1164211yxe.1 for ; Wed, 28 Oct 2009 15:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=sofPHzbqlSJD7dQoMi6jSmi2Yj8/KEL/voHT0AgHFmU=; b=MYBxAHOokqQOOciBBosW3HGGgLVJHUcooC1fYO424rTCF+LtN1Y3ui/69oicapAudK 0sn2Av0S++jE7hE2AUGzLbizpjHp8vc+VE76wuH4yXEt+5dUBKogpkZRKn5NMDwP2XWS aeolJKOhxYZsh+uCPqmFiuF+XzmJDItttxViI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=qsUSl2uXOjRwzjVeckht+i4wYtv1scKDnzoImLS1OuRihw5PZt2ZMRZktneqwNsY4k ytL0QXP+iVHMe5yIdgkSCWGsS4ADNcLaBey3CkckfPMQ7e/HO6R9dHEXyQ84nZjswqb6 YQ3NtmHaBaKqfFdFPSMN+PQ3g1CcQpUOgbL4o= MIME-Version: 1.0 Received: by 10.101.130.31 with SMTP id h31mr725570ann.41.1256770086561; Wed, 28 Oct 2009 15:48:06 -0700 (PDT) In-Reply-To: <87tyxj5rkv.fsf@frosties.localdomain> References: <87eiond3of.fsf@frosties.localdomain> <87639zd0m9.fsf@frosties.localdomain> <87tyxj5rkv.fsf@frosties.localdomain> Date: Wed, 28 Oct 2009 23:48:06 +0100 Message-ID: <527cf6bc0910281548s53a00ec9s99402f4249b2d411@mail.gmail.com> Subject: Re: [Caml-list] Re: How to read different ints from a Bigarray? From: blue storm To: Goswin von Brederlow Cc: Sylvain Le Gall , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; bigarray:01 buf:01 camlp:01 storm:98 28,:98 2009:98 char:01 wrote:01 ints:01 caml-list:01 int:01 int:01 off-topic:02 match:02 declaration:02 On Wed, Oct 28, 2009 at 6:57 PM, Goswin von Brederlow wrote: > Maybe ideal would be a format string based interface that calls C with > a format string and a record of values. Because what I really need is > to read/write records in an architecture independend way. Something > like > > type t = { x:int; y:char; z:int64 } > let t_format = "%2u%c%8d" > > put_formated buf t_format t > > But how to get that type safe? Maybe a camlp4 module that generates > the format string and type from a single declaration so they always > match. It's possibly off-topic, but you might be interested in Richard Jones's Bitstring project [1] wich deals with similar issues quite nicely in my opinion. [1] http://code.google.com/p/bitstring/