English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] kprintf question (was printf question)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <vanicat@l...>
Subject: Re: [Caml-list] kprintf question
Damien <Damien.Pous@ens-lyon.fr> writes:

> hi,
>
> I've got three questions about Printf.kprintf :
>
>  * why has it type
> 	(string -> string) -> ('a, unit, string) format -> 'a
> and not 
> 	(string -> 'b) -> ('a, unit, 'b) format -> 'a
>
> this would allow to make _exactly_ what we want within the
> continuation.

because 3.06 format type lack a fourth argument :
        Objective Caml version 3.06+31 (2003-05-02)

# Printf.kprintf;;
- : (string -> 'a) -> ('b, unit, string, 'a) format -> 'b = <fun>

in 3.06 the fourth argument doesn't exist and is replaced by the
third, but in the kprintf case, they are intuitively different (but
they are intuitively equal in all other printf like function).

(the fourth argument is needed for the %a format :
# ("%a" : ('a, 'b, 'c, 'd) format);;
- : (('a -> 'b -> 'c) -> 'b -> 'd, 'a, 'c, 'd) format = <abstr>
)



> * why is it _pseudo_ polymorphic ?
> # Printf.kprintf (fun s -> prerr_endline s; "");;
> - : ('_a, unit, string) format -> '_a = <fun>

it is not kprintf problem, it is general problem : in ocaml 3.06,
the result of an application cannot be polymorphic. It is a FAQ, read
it. 

[...]


-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat

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