From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA07529; Wed, 22 Aug 2001 20:53:46 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA07387 for ; Wed, 22 Aug 2001 20:53:45 +0200 (MET DST) Received: from woozle.org (woozle.org [216.39.146.229]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f7MIrif27820 for ; Wed, 22 Aug 2001 20:53:44 +0200 (MET DST) Received: from neale by woozle.org with local auth=neale (Exim 3.12 #1 (Debian)) id 15Zd8J-0001AS-00 for ; Wed, 22 Aug 2001 11:53:43 -0700 From: neale-caml@woozle.org To: caml-list@pauillac.inria.fr Subject: [Caml-list] Str.string_match raising Invalid_argument "String.sub" in gc Organization: WoozleWorks (woozle.org) X-Face: "&g4:h\nuA>dfRaRmJ5c+Mqvu!,|5@dd>:BqJ,#G:mT3`i-EF{L>6oE?di}m\;Wil(?AS(@9j"G@o-UR8(BU$)u.%I;*K9%4Vj.fO$W9-bjxPgl%|#{^W@e#1/jZ@,G:>&;JzJrBqMqomx3Z#Hg.``g5v%R[+PzjYtAa&l@EtK{R<;.,gV`5$8Go1OJB=L`R(<)U$M4YK-t;a}oA1y([AV@r$%?AJW[:_|_*r44[Gl{3@:Ff6U9XFOJxp%lZWI-d0-1l5+6aMAOAT+Ac%q@E3t|:2;lpSwi=1"gf7g{Bz+U2MI X-PGP-Key-Fingerprint: A862 F105 13EF 7FAF 4F08 78B4 9168 856B 48BF F157 Date: 22 Aug 2001 11:53:43 -0700 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Capitol Reef) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I'm converting over some examples from the Perl cookbook to learn OCaml and help with the PLEAC project , and I'm running into some strange behavior with the Str structure; I think it's something to do with garbage collection. # let rec f l = let sep = Str.regexp "^[ \t\n]*\\(.+\\)" in match l with | [] -> [] | [""] -> [] | s :: rest -> if (Str.string_match sep s 0) then let foo = print_string ("match " ^ Str.matched_group 1 s ^ "\n") in (Str.matched_group 1 s) :: (f rest) else let foo = print_string "nomatch\n" in (f rest);; val f : string list -> string list = # f [" arf"];; match arf - : string list = ["arf"] # f [" arf"; "barf"];; match arf match barf - : string list = [" ar"; "barf"] # f [" arf"; " barf"];; match arf match barf Uncaught exception: Invalid_argument "String.sub". First question: why is f [" arf"] = ["arf"] while f [" arf"; "barf"] = [" ar"; "barf"] ? I don't think I've entered any code which should modify the string after it's been matched. Second question: What is causing the Invalid_argument exception? Thanks in advance for any assistance, Neale ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr