caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] kprintf question (was printf question)
@ 2003-05-19 10:00 Damien
  2003-05-19 12:06 ` [Caml-list] kprintf question Remi Vanicat
  0 siblings, 1 reply; 2+ messages in thread
From: Damien @ 2003-05-19 10:00 UTC (permalink / raw)
  To: caml-list

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.


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


* couldn't Printf export a dummy function 
	zprintf: ('a, 'b, unit) format -> 'a 
that does nothing !
this would allow a more efficient debugging function in the code I've
just posted (printf question), without inserting ugly Obj.magics.


thanks,
damien

-- 
<http://www.ens-lyon.fr/~dpous>

-------------------
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 question
  2003-05-19 10:00 [Caml-list] kprintf question (was printf question) Damien
@ 2003-05-19 12:06 ` Remi Vanicat
  0 siblings, 0 replies; 2+ messages in thread
From: Remi Vanicat @ 2003-05-19 12:06 UTC (permalink / raw)
  To: caml-list

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


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

end of thread, other threads:[~2003-05-19 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-19 10:00 [Caml-list] kprintf question (was printf question) Damien
2003-05-19 12:06 ` [Caml-list] kprintf question Remi Vanicat

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