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

Re: Character string example doesn't work

Expand Messages
  • vly3
    ... Thanks. I have submitted it to the Caml bug tracking system which assigned it # 3465. - Vincent
    Message 1 of 6 , Feb 13, 2005
    • 0 Attachment
      --- In ocaml_beginners@yahoogroups.com, Remi Vanicat
      <remi.vanicat@g...> wrote:
      > On Sun, 13 Feb 2005 15:24:27 -0000, vly3 <vly3@y...> wrote:
      > >
      > >
      > > Now I am going through Jason Hickey's Introduction to Ocaml, and have
      > > encountered an anomaly in section 2.1.5 string: character strings.
      > > This example given in the book does not come out as advertized when I
      > > type it into the Ocaml interpreter.
      > >
      > > # Printf.printf "%s" ("Hello " ^ "world\000Not a terminator\n");;
      > >
      > > According to the book, I am supposed to get this:
      > >
      > > Hello worldNot a terminator
      > > - : unit = ()
      > >
      > > Instead, what I get is this:
      > >
      > > Hello world
      > >
      > > and the cursor sits blinking after the "d" of world.
      > >
      > > Is this a bug in the Ocaml implementation? I am using the Native
      > > Win32 port based on the MinGW toolchain (3.08.2) under Windows XP.
      >
      > Well, it is a problem with your port of ocaml, There is no problem
      > with ocaml 3.08.2 on linux.
      >
      > It is still a bug, and you should report it for the ocaml team to
      > investigate it.

      Thanks. I have submitted it to the Caml bug tracking system which
      assigned it # 3465.

      - Vincent
    • Rahul Siddharthan
      ... I see the problem with ocaml 3.08.2 on debian (the debian package). $ uname -a Linux greenrondo 2.6.8.1 #4 Mon Oct 18 22:51:02 IST 2004 i686 GNU/Linux $
      Message 2 of 6 , Feb 13, 2005
      • 0 Attachment
        Remi Vanicat said on Feb 13, 2005 at 17:25:46:
        > On Sun, 13 Feb 2005 15:24:27 -0000, vly3 <vly3@...> wrote:
        > >
        > > Now I am going through Jason Hickey's Introduction to Ocaml, and have
        > > encountered an anomaly in section 2.1.5 string: character strings.
        > > This example given in the book does not come out as advertized when I
        > > type it into the Ocaml interpreter.
        > >
        > > # Printf.printf "%s" ("Hello " ^ "world\000Not a terminator\n");;
        > >
        > > According to the book, I am supposed to get this:
        > >
        > > Hello worldNot a terminator
        > > - : unit = ()
        > >
        > > Instead, what I get is this:
        > >
        > > Hello world
        > >
        > > and the cursor sits blinking after the "d" of world.
        > >
        > > Is this a bug in the Ocaml implementation? I am using the Native
        > > Win32 port based on the MinGW toolchain (3.08.2) under Windows XP.
        >
        > Well, it is a problem with your port of ocaml, There is no problem
        > with ocaml 3.08.2 on linux.

        I see the problem with ocaml 3.08.2 on debian (the debian package).

        $ uname -a
        Linux greenrondo 2.6.8.1 #4 Mon Oct 18 22:51:02 IST 2004 i686 GNU/Linux
        $ ocaml
        Objective Caml version 3.08.2

        # Printf.printf "%s" ("Hello " ^ "world\000Not a terminator\n");;
        Hello world<CURSOR_STAYS_HERE>

        Rahul
      • Martin Jambon
        ... That seems to be related to the terminal being used, not ocaml. For this example, I suggest using printf %S (capital S) instead: $ ledit ocaml Objective
        Message 3 of 6 , Feb 13, 2005
        • 0 Attachment
          On Mon, 14 Feb 2005, Rahul Siddharthan wrote:

          > # Printf.printf "%s" ("Hello " ^ "world\000Not a terminator\n");;
          > Hello world<CURSOR_STAYS_HERE>

          That seems to be related to the terminal being used, not ocaml.
          For this example, I suggest using printf "%S" (capital S) instead:

          $ ledit ocaml
          Objective Caml version 3.08.2

          # Printf.printf "%S" ("Hello " ^ "world\000Not a terminator\n");;
          "Hello world\000Not a terminator\n"- : unit = ()


          Martin

          --
          Martin Jambon, PhD
          Researcher in Structural Bioinformatics since the 20th Century
          The Burnham Institute http://www.burnham.org
          San Diego, California
        • vly3
          ... The capital %S works okay on my system in Windows XP. Only the lower case %s hangs where the 000 is. The bug (if it is one) also shows if you just
          Message 4 of 6 , Feb 13, 2005
          • 0 Attachment
            --- In ocaml_beginners@yahoogroups.com, Martin Jambon
            <martin_jambon@e...> wrote:

            > That seems to be related to the terminal being used, not ocaml.
            > For this example, I suggest using printf "%S" (capital S) instead:

            > # Printf.printf "%S" ("Hello " ^ "world\000Not a terminator\n");;
            > "Hello world\000Not a terminator\n"- : unit = ()


            The capital "%S" works okay on my system in Windows XP. Only the
            lower case "%s" hangs where the \000 is. The bug (if it is one) also
            shows if you just do

            Printf.printf "%s" "hello\000world";;

            in which case it prints

            hello<cursor stays here>

            If I compile it and run from the command line, the whole line prints
            okay. So it does only happen in the terminal.

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