caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] kprintf
@ 2002-08-15 14:52 Christophe Delage
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe Delage @ 2002-08-15 14:52 UTC (permalink / raw)
  To: caml-list

Hi,
     I saw that this function has just been added to ocaml,
I think this is a good idea, but I am wondering why
the continuation function should return a string.
I wrote once, for my programs, a "kprintf-like" function
with _exactly_ the same code (there is not much difference between
sprintf and kprintf ;-), but I forced the type :

 mykprintf : (string -> 'b) -> ('a, string -> 'b, 'b) format -> 'a

and (as far as I know) there were no problems,

 mykprintf f fmt a1 .. an

seems to do the same thing (and have the same type) as

 f (mykprintf fmt a1 .. an)

whatever the return type of f is.

I saw a post in the list about "technical reasons",
could somebody be more precise ?

-Christophe

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re:  [Caml-list] kprintf
@ 2002-08-23 12:56 Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 2002-08-23 12:56 UTC (permalink / raw)
  To: caml-list, cdelage

>From: Christophe Delage <cdelage@ens-lyon.fr>

> mykprintf : (string -> 'b) -> ('a, string -> 'b, 'b) format -> 'a
>
>and (as far as I know) there were no problems,

Consider this:

   mykprintf f "%a" g x

If x has type 'c, then g must have type (string -> 'b) -> 'c -> 'b;
mykprintf will call (g f x) and insert the result (which has type 'b)
in the string that will be passed to f as argument.  This can only
make sense if 'b = string.

-- Damien
-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-23 12:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-15 14:52 [Caml-list] kprintf Christophe Delage
2002-08-23 12:56 Damien Doligez

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).