Loading ...
Sorry, an error occurred while loading the content.

Converting a tree from C to Ocaml.

Expand Messages
  • sramam
    Folks, I am new to Ocaml, and am trying to determine feasability of it s use for my purposes. ... I have a C library which stores a tree structure on Disk. The
    Message 1 of 2 , May 28, 2004
    • 0 Attachment
      Folks,
      I am new to Ocaml, and am trying to determine feasability
      of it's use for my purposes.

      The task :
      --------
      I have a C library which stores a tree structure on Disk.
      The nodes of the tree are polymorphic - with a large number
      of types. There is a need for persistence on this data.
      My goal is to read this data and do some processing on it.
      The goal is to implement the processing in Ocaml.

      I am wondering what is the best way to do this.

      My ideas :
      --------
      One mechanism I was considering was to use SWIG to interface
      and drive the C functions from Ocaml. And then use Marshal
      Module's functionality for the persistence effort.

      A question that I am getting stumped on -
      How does one convert trees/nodes from C to Ocaml? Does this
      have to be a copy operation?

      A second mechanism was to use a C program to write data to disk,
      and do the conversion on reading these into Ocaml.
      I am not sure I understand how to do this completely yet -
      since it is binary data, and given the polymorphism, it might be
      a lot of (tedious) work.

      The Plea (!) :
      ------------
      I would appreciate any pointers/recommendations on how to
      go about this task. Any comments on the relative complexity
      of the two mechanisms would also be appreciated.

      Thanks,
      -Shishir
    • Stalkern 2
      ... Why not use a human-readable tree-like file such as a XML-file? Of course you d better either resolve the binary blobs, or store just their location and
      Message 2 of 2 , May 31, 2004
      • 0 Attachment
        Il Friday 28 May 2004 21:55, sramam ha scritto:
        > Folks,
        > I am new to Ocaml, and am trying to determine feasability
        > of it's use for my purposes.
        >
        > The task :
        > --------
        > I have a C library which stores a tree structure on Disk.
        > The nodes of the tree are polymorphic - with a large number
        > of types. There is a need for persistence on this data.
        > My goal is to read this data and do some processing on it.
        > The goal is to implement the processing in Ocaml.
        >
        > I am wondering what is the best way to do this.
        >
        > My ideas :
        > --------
        > One mechanism I was considering was to use SWIG to interface
        > and drive the C functions from Ocaml. And then use Marshal
        > Module's functionality for the persistence effort.
        >
        > A question that I am getting stumped on -
        > How does one convert trees/nodes from C to Ocaml? Does this
        > have to be a copy operation?
        >
        > A second mechanism was to use a C program to write data to disk,
        > and do the conversion on reading these into Ocaml.
        > I am not sure I understand how to do this completely yet -
        > since it is binary data, and given the polymorphism, it might be
        > a lot of (tedious) work.
        >
        > The Plea (!) :
        > ------------
        > I would appreciate any pointers/recommendations on how to
        > go about this task. Any comments on the relative complexity
        > of the two mechanisms would also be appreciated.
        >
        > Thanks,
        > -Shishir
        >
        >

        Why not use a human-readable tree-like file such as a XML-file? Of course
        you'd better either resolve the binary blobs, or store just their location
        and rely over your helper functions. You could use the Polymorphic Xml Parser
        by Gerd Stolpmann.

        According to my experience, it is a safe choice to use XML, because
        you give out structure and data together, you can be very precise by using
        attributes (such as for data types), and use DTDs to control what you get and
        what you give out, and in case PXP does not fulfill your needs yet (!), it is
        not too difficult to write a parser yourself.

        Hope it helps

        Ernesto
      Your message has been successfully submitted and would be delivered to recipients shortly.