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

Re: "ocaml_beginners"::[] open_process blues (was catching stderr)

Expand Messages
  • Remi VANICAT
    ... I should have test my program before posting it. In fact, I was thinking of something like : let f () = let b = Unix.open_process_in ls in try while true
    Message 1 of 12 , Jun 14, 2002
    • 0 Attachment
      Tom Hirschowitz <Tom.Hirschowitz@...> writes:

      > Is this what you want?
      >
      > let f () =
      > let b = Unix.open_process_in "ls" in
      > try
      > while true do
      > let line = input_line b in
      > print_endline line
      > done
      > with
      > | End_of_file -> let _ = Unix.close_process_in b in ()

      I should have test my program before posting it. In fact, I was thinking
      of something like :


      let f () =
      let b = Unix.open_process_in "ls" in
      try
      while true do
      let line = input_line b in
      print_endline line
      done;
      (* this should never be executed *)
      assert false
      with
      | End_of_file -> Unix.close_process_in b

      To have the process_status at the end of the function.

      --
      RĂ©mi Vanicat
      vanicat@labri.u-bordeaux.fr
      http://dept-info.labri.u-bordeaux.fr/~vanicat
    • Johann Spies
      ... Yes, thanks. I must still grow into the Ocaml way of thinking about types. Especially the use of () is something I must get used to. Regards. Johann --
      Message 2 of 12 , Jun 14, 2002
      • 0 Attachment
        On Fri, Jun 14, 2002 at 03:08:51PM +0200, Tom Hirschowitz wrote:
        >
        > Is this what you want?

        Yes, thanks. I must still grow into the Ocaml way of thinking about
        types.

        Especially the use of () is something I must get used to.

        Regards.

        Johann
        --
        Johann Spies Telefoon: 021-808 4036
        Informasietegnologie, Universiteit van Stellenbosch

        "I beseech you therefore, brethren, by the mercies of
        God, that ye present your bodies a living sacrifice,
        holy, acceptable unto God, which is your reasonable
        service." Romans 12:1
      • Johann Spies
        ... Thank you for this explanation. This cleared something I never understood before. I was thinking previously that the only use for assert wat when
        Message 3 of 12 , Jun 14, 2002
        • 0 Attachment
          On Fri, Jun 14, 2002 at 03:26:09PM +0200, Frederic van der Plancke wrote:
          >
          > "assert false" will trigger an AssertError (is that the real name ?)
          > if executed, and the nice thing is that, thanks to a compiler hack,
          > its return type is 'a and can be identified with anything, in
          > particular with Unix.process_status, so the above code
          > compiles. (And f returns the final Unix.process_status).

          Thank you for this explanation. This cleared something I never
          understood before. I was thinking previously that the only use for
          assert wat when debugging a program.

          And thank you to everybody who responded.

          Regards.
          Johann
          --
          Johann Spies Telefoon: 021-808 4036
          Informasietegnologie, Universiteit van Stellenbosch

          "I beseech you therefore, brethren, by the mercies of
          God, that ye present your bodies a living sacrifice,
          holy, acceptable unto God, which is your reasonable
          service." Romans 12:1

          > LocalWords: explanation
        Your message has been successfully submitted and would be delivered to recipients shortly.