Re: polymorphic variants

From: Markus Mottl (mottl@miss.wu-wien.ac.at)
Date: Fri Jun 09 2000 - 21:04:59 MET DST

  • Next message: Brent Fulgham: "RE: Reverse-Engineering Bytecode: A Possible Commercial Objection To O'Caml"

    On Fri, 09 Jun 2000, David Chemouil wrote:
    > The problem is that, as server communicate for admistrative reasons,
    > they exchange messages with arguments of which I already know the type
    > constructor.
    >
    > As a consequence, the servers must manipulate a type 'argument' which is
    > not yet completely defined: the part interesting the servers is defined
    > but not the one interesting the generated OCaml program.

    Maybe you would want to try something like this (uses the Marshal module):

      type admin_args = ...
      type user_data = string
      type argument = MsgA of admin_args * user_data | MsgB of ... | ...

    Then you can react to messages as follows, for example:

      let recv = function
        | MsgA (adm_args, user_data) ->
            handle_adm_args adm_args;
            call_user_program (Marshal.from_string user_data)
        | MsgB ... ->
        ...

    Sending would be something like:

      let send user_data =
        let adm_args = create_args ()
        and contents = Marshal.to_string user_data [Closures] in
        send_network (MsgA (adm_args, contents))

    Very rudimentary, but the basic idea (keep user data encoded in a string
    until needed) should be clear...

    Best regards,
    Markus Mottl

    -- 
    Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
    



    This archive was generated by hypermail 2b29 : Mon Jun 12 2000 - 16:03:52 MET DST