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

Re: "ocaml_beginners"::[] List hd error

Expand Messages
  • Adrian
    well i got the error. The error is in parsePGP.ml line 150. let mpi = List.hd mpis in { pk_version = version; pk_ctime = creation_time; pk_expiration = (match
    Message 1 of 11 , Mar 2, 2012
    • 0 Attachment
      well i got the error. The error is in parsePGP.ml line 150.

      let mpi = List.hd mpis in
      { pk_version = version;
      pk_ctime = creation_time;
      pk_expiration = (match expiration with Some 0 -> None | x -> x);
      pk_alg = algorithm;
      pk_keylen = mpi.mpi_bits;
      }

      the task of the program is to dump the database. How can i kill the error without killing the structure of data?

      Adrian


      From: Gabriel Scherer
      Sent: Tuesday, February 28, 2012 7:37 PM
      To: ocaml_beginners@yahoogroups.com
      Cc: rixed@...
      Subject: Re: "ocaml_beginners"::[] List hd error


      All of this is rather moot: with the backtrace information enabled, as
      suggested by Esther, the precise place where the error happens will be
      available -- so there is no more need, for example, to litter the code
      with "assert false" to get location informations. I second the
      recommendation not to use List.hd and List.tl, though, pattern
      matching forces to handle the failure case and is almost always
      better. If you know statically that the list is always non-empty, then
      at least write a comment to justify invariant.

      On Tue, Feb 28, 2012 at 3:59 PM, Esther Baruk <mailto:esther.baruk%40gmail.com> wrote:
      > Yes you're right, my mistake!
      >
      >
      > Esther Baruk
      >
      >
      > On Tue, Feb 28, 2012 at 3:39 PM, <mailto:rixed%40happyleptic.org> wrote:
      >
      >> **
      >>
      >>
      >> -[ Tue, Feb 28, 2012 at 03:32:48PM +0100, Esther Baruk ]----
      >>
      >> > No, it would not work since exceptions cannot be manipulated like other
      >> > values, they cannot be passed as argument of a function.
      >>
      >> They can. Exceptions are values of type exn:
      >>
      >> # let raiseme e = raise e;;
      >> val raiseme : exn -> 'a = <fun>
      >> # exception Bla of int;;
      >> exception Bla of int
      >> # raiseme (Bla 10);;
      >> Exception: Bla 10.
      >>
      >>
      >>
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      > ------------------------------------
      >
      > Archives up to December 31, 2011 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners
      > The archives of the very official ocaml list (the seniors' one) can be found at http://caml.inria.fr
      > Attachments are banned and you're asked to be polite, avoid flames etc.Yahoo! Groups Links
      >
      >
      >




      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.