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 LAA16193; Fri, 4 Oct 2002 11:21:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA16614 for ; Fri, 4 Oct 2002 11:21:54 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a160.tin.it [62.211.4.160]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g949LqD20236; Fri, 4 Oct 2002 11:21:53 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 08C6027246; Fri, 4 Oct 2002 11:31:52 +0200 (CEST) Message-ID: <3D9D6008.9010206@baretta.com> Date: Fri, 04 Oct 2002 11:31:52 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: Pierre Weis , Ocaml Subject: Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) References: <200210040907.LAA15958@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Pierre Weis wrote: > This is not a mini-bug, this is a carefully crafted feature and > thoroughly considered design decision :( > > "%[]" is not allowed because we need to allow the matching of the > closing bracket. Hence, if ']' just follows the opening bracket (or > the ^ character, in case of negative range) it is considered as a > plain ']' (or ascii code 93) to be matched. > > So "%[]]" means matching ']' (well, more precisely zero or more ']'); > more generally, "%[]range]" means matching ']' or range; "%[^]range]" > means matching any character different from ']' and not belonging to > range. I probably did not consider the problem thoroughly enough. I was expecting "%[]]" to match a range of ']' and "%[]" to match the empty range of characters (which is a rather useless construct anyway, as you point out). Now I realize this would render almost impossible the interpretation of a such a format as "%[]abcdefg...": you simply never know if it is the prefix of a range conversion specifier or a empty range conversion specifier followed by a string constant specifier. While the empty range conversion is admittedly useless, a full range conversion is a whole different story. Coding it as "%[\000-\255]" is possible, but maybe it would useful to add a "%z" specifier to mean "read till the end of input". What do you think? Alex ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners