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 TAA00450; Fri, 12 Jul 2002 19:43:15 +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 TAA00446 for ; Fri, 12 Jul 2002 19:43:14 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6CHhDf11669; Fri, 12 Jul 2002 19:43:13 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA00439; Fri, 12 Jul 2002 19:43:13 +0200 (MET DST) From: Pierre Weis Message-Id: <200207121743.TAA00439@pauillac.inria.fr> Subject: Re: [Caml-list] Scanf [was: Productivity improvement] In-Reply-To: <3D2EDA5B.2050102@baretta.com> from Alessandro Baretta at "Jul 12, 102 03:32:11 pm" To: alex@baretta.com (Alessandro Baretta) Date: Fri, 12 Jul 2002 19:43:13 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alex wrote: > > However, if what you dislike about those functions is the conciseness > > of the format strings, there is not much to say ... > > > > Not the conciseness, of course. I dislike the lack of > readability of format strings. I'd like to write: > let format = int + float + float + string + int > and, voilą mon format! Then there would have to be some > additional details such as having a scanf function taking an > in_channel, a format such as the above, and So, I think what you want a format concatenation primitive to build-up your format from small pieces. Supposing this primitive is available and named ( ^^ ) you would write: let format = "%i" ^^ "%f" ^^ "%f" ^^ "%s" ^^ "%i" I agree with you that this primitive is lacking from the current system. However, as already mentioned by Damien some weeks ago, by Xavier a long time ago, and by me in this thread, it is possible to add such a primitive, if we add an extra type variable to the format type constructor. This would be slightly not backward compatible for people that use to add explicit type constraints with format types in their programs, something like (expression : (int, bool, string) format) I'm curious to know if there are many users of Objective Caml that ever used such a complex type constraint ??? (The Caml implementors being excepted evidently, since these constraints are necessary to define printf and scanf in the first place) If somebody would object about adding a fourth type variable to the format constructor, please let me know (drop me a message directly, it is useless to bother this mailing list). > IOW, you are telling me I should study the details of the > machinery behind scanf and printf. I will. But I still > wonder if I can cook up a working, toy example, of the > scanf-I've-always-dreamt-of-but-never-dared-to-code. > > Alex Sure, you should give it a serious try and let us know when you get something that works. All the best, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- 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