caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <pierre.weis@inria.fr>
To: alex@baretta.com (Alessandro Baretta)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Scanf [was: Productivity improvement]
Date: Fri, 12 Jul 2002 19:43:13 +0200 (MET DST)	[thread overview]
Message-ID: <200207121743.TAA00439@pauillac.inria.fr> (raw)
In-Reply-To: <3D2EDA5B.2050102@baretta.com> from Alessandro Baretta at "Jul 12, 102 03:32:11 pm"

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


      reply	other threads:[~2002-07-12 17:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200207121224.OAA24345@pauillac.inria.fr>
2002-07-12 13:32 ` Alessandro Baretta
2002-07-12 17:43   ` Pierre Weis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200207121743.TAA00439@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=alex@baretta.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).