caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Roewen <jonathan.roewen@gmail.com>
To: caml-list@yquem.inria.fr
Subject: [Caml-list] Making something similar to format[4]
Date: Sun, 26 Jun 2005 23:07:35 +1200	[thread overview]
Message-ID: <ad8cfe7e05062604075c5d4629@mail.gmail.com> (raw)

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 = 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
stage.

Jonathan


             reply	other threads:[~2005-06-26 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-26 11:07 Jonathan Roewen [this message]
2005-06-26 15:10 ` Richard Jones

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=ad8cfe7e05062604075c5d4629@mail.gmail.com \
    --to=jonathan.roewen@gmail.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).