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 UAA06568; Thu, 23 Aug 2001 20:23:30 +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 UAA06524 for ; Thu, 23 Aug 2001 20:23:29 +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 f7NINSH02890 for ; Thu, 23 Aug 2001 20:23:28 +0200 (MET DST) Received: from neale by woozle.org with local auth=neale (Exim 3.12 #1 (Debian)) id 15Zyzi-00005m-00 for ; Thu, 23 Aug 2001 11:14:18 -0700 To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Str.string_match raising Invalid_argument "String.sub" in gc References: From: Neale Pickett 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: 23 Aug 2001 11:14:18 -0700 In-Reply-To: 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 Alain Frisch writes: > On 23 Aug 2001, Neale Pickett wrote: >> If this is the case, why does Str.matched_group even bother requiring >> the original string? > Indeed, you shouldn't. > The manual says: > << > val matched_string: string -> string > matched_string s returns the substring of s that was matched by the latest > string_match, search_forward or search_backward. The user must make sure > that the parameter s is the same string that was passed to the matching or > searching function. > >> > Note the "latest". Yes, there it is; now I feel a little silly. > The approach you suggest (that the library keeps a reference to the > last matched string) is acceptable. I guess it was not implemented > like that because this would prevent garbage collection of the last > matched string. (maybe a "release_internal_buffer" function would > have been better) Hmm. I'm beginning to see the delimna. I don't suppose there's an exposed function that will return the memory address of the string, either, but if there were, that could be used to keep track of what string was last passed in. Maybe the proper solution is to use Markus Mottl's PCRE-OCaml library :-) Thanks for your patience. I understand a lot more about OCaml than I did yesterday! 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