caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alessandro Baretta <alex@baretta.com>
To: Ken Wakita <wakita@is.titech.ac.jp>
Cc: Cezary Kaliszyk <ck189400@zodiac.mimuw.edu.pl>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] format type
Date: Mon, 04 Nov 2002 08:54:13 +0100	[thread overview]
Message-ID: <3DC627A5.9090900@baretta.com> (raw)
In-Reply-To: <B9EC1FD6.11DA2%wakita@is.titech.ac.jp>



Ken Wakita wrote:
> Did you try "%t"?
> 
> Printf.printf "%t": (out_channel -> unit) -> unit = <fun>

Since Cezary mentions parsing, I suppose he meant Scanf, 
rather than Printf.

> You could simply ignore out_channel if you are not interested.
> 
> Ken Wakita
> 
> 
>>From: Cezary Kaliszyk <ck189400@zodiac.mimuw.edu.pl>
>>Date: Sun, 3 Nov 2002 08:08:58 +0100
>>To: caml-list@inria.fr
>>Subject: [Caml-list] format type
>>
>>I'm trying to write a function that takes a format and a function and
>>applies some (got from elsewere) arguments to the function.
>>
>><snip>
>>
>>The only known workaround for me for now is to pass "%t" and
>>make my function not (unit -> unit) but ('a -> unit).

As far as I can see from the docs, "%t" is only meaningful 
with the Printf module. I see no mention of it in Scanf. 
What exactly are you trying to do anyway?

Assuming you are talking about the Scanf module, I'd say you 
can't. Of course, if your function takes a unit input, it 
can very well be a perfectly polymorphic function (à la 
ignore) with type ('a -> unit). In which case you can force 
a call to such function while scanning the input buffer by 
passing it a range conversion with an empty range: 
"%[^\000-\255]". Your function would be called with an empty 
string as an actual parameter.

Or, better yet, you can use the "%N" conversion, which 
passes the number of characters consumed. Just discard this 
value.

>>Writing code with changed types just for the sake of the language is
>>very bad. And with "%t" 'a seems to be (unit -> unit).

It is also very bad to complain without doing any work 
yourself. You are probably the only one on this list wishing 
to call a function with no input while parsing a buffer. 
Nothing wrong with this, apart from stylistic 
considerations, but it implies two things: 1) I don't 
suppose Pierre ever even thought of such a conversion for 
Scanf, and 2) even if he did, I doubt he'd care to implement 
it. If you really think it is necessary, you might consider 
hacking it into the Scanf module and submitting the patch to 
the maintainers.

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


  reply	other threads:[~2002-11-04  7:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-03  7:08 Cezary Kaliszyk
2002-11-04  4:00 ` Ken Wakita
2002-11-04  7:54   ` Alessandro Baretta [this message]
2002-11-04 11:03     ` Cezary Kaliszyk
2002-11-04 11:56       ` Alessandro Baretta

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=3DC627A5.9090900@baretta.com \
    --to=alex@baretta.com \
    --cc=caml-list@inria.fr \
    --cc=ck189400@zodiac.mimuw.edu.pl \
    --cc=wakita@is.titech.ac.jp \
    /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).