From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA03655; Wed, 21 Jul 2004 17:53:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA01739 for ; Wed, 21 Jul 2004 17:53:01 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i6LFqvSH025006; Wed, 21 Jul 2004 17:52:58 +0200 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA04351; Wed, 21 Jul 2004 17:52:57 +0200 (MET DST) From: Pierre Weis Message-Id: <200407211552.RAA04351@pauillac.inria.fr> Subject: Re: [Caml-list] kprintf with user formatters In-Reply-To: <200407191143.12082.postmaster@jdh30.plus.com> from Jon Harrop at "Jul 19, 104 11:43:12 am" To: postmaster@jdh30.plus.com (Jon Harrop) Date: Wed, 21 Jul 2004 17:52:57 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40FE9159.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; pierre:01 weis:01 pierre:01 weis:01 caml-list:01 kprintf:01 formatters:01 2004:99 endline:01 endline:01 val:01 toto:01 val:01 printf:01 expr:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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 = > # (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.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