Browse thread
[Caml-list] kprintf with user formatters
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Pierre Weis <pierre.weis@i...> |
| Subject: | Re: [Caml-list] kprintf with user formatters |
> On Monday 19 July 2004 11:10, Pierre Weis wrote: > > They also can have the wrong idea that arguments are not evaluated > > (since there is no need to convert them to string) which is wrong. > > Forgive me if this is irrelevant (I've failed to understand all of your > discussion) but can this be tied in with a general way to define functions > with specified argument evaluation, e.g. to define your own, short-circuit- > evaluated && operator: > > # (print_endline "1"; false) && (print_endline "2"; true);; > 1 > - : bool = false > # let (&&) a b = a && b;; > val ( && ) : bool -> bool -> bool = <fun> > # (print_endline "1"; false) && (print_endline "2"; true);; > 2 > 1 > - : bool = false > > Not that I need such a thing... > > Cheers, > Jon. Yes this remark is completely relevant: the built-in && and || operators and the if then else construct (considered as a 3 places operator) are the only lazy constructs of the language. Well we now have another extra lazy construction that allows lazy evaluation, as in: let x = lazy (print_string "toto");; val x : unit lazy_t = <lazy> Lazy.force x;; toto- : unit = () So we could imagine a lazy version of printf that only accepts 'a lazy_t arguments and would have to force their evaluation to print them. This way, a global flag may ask lazyprintf to skip everything. The drawback is that you would have to write (lazy expr) for each argument ``expr'' to be printed. Quite a bit intrusive, I think. Best regards, 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