[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pierre Weis <pierre.weis@i...> |
| Subject: | Re: [Caml-list] Scanf [was: Productivity improvement] |
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