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 XAA29293; Thu, 14 Jun 2001 23:35:29 +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 XAA29383 for ; Thu, 14 Jun 2001 23:35:28 +0200 (MET DST) Received: from mail.cs.uu.nl (sunset.cs.uu.nl [131.211.80.32]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f5ELZSX23092; Thu, 14 Jun 2001 23:35:28 +0200 (MET DST) Received: from silvester.cs.uu.nl (silvester.cs.uu.nl [131.211.80.119]) by mail.cs.uu.nl (Postfix) with SMTP id 954B94518; Thu, 14 Jun 2001 23:35:27 +0200 (MET DST) Received: by silvester.cs.uu.nl (sSMTP sendmail emulation); Thu, 14 Jun 2001 23:35:27 +0200 Date: Thu, 14 Jun 2001 23:35:27 +0200 From: Frank Atanassow To: Pierre Weis Cc: Hendrik Tews , caml-list@inria.fr Subject: Re: [Caml-list] pretty printers and format and matrices Message-ID: <20010614233527.A3906@cs.uu.nl> References: <15143.22914.894206.676827@gargle.gargle.HOWL> <200106141937.VAA27299@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200106141937.VAA27299@pauillac.inria.fr>; from Pierre.Weis@inria.fr on Thu, Jun 14, 2001 at 09:37:44PM +0200 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Pierre Weis wrote (on 14-06-01 21:37 +0200): > On a regular machine this allows to simultaneously open no more than > 4611686018427387903 boxes, which could be large enough to pretty print > a huge source chunk of your programming language source programs. On > the other hand, on my Ipaq handheld this limit is much smaller than > that, namely 1073741823 which may be really short for you. > > If you need more than max_int simultaneously open boxes, you should > rewrite the Format module using the bignumbers facility of > Caml. However, I should admit that you will still be facing another > stupid limit (no more than 2^30 words in a big integer, which means > approximately 9 * 2 ^ 30 decimal digits on a little machine, once more > far far away from infinity). If you really need infinity, I am not aware > of any practical solution in Objective Caml. > > Sorry for this unsatisfactory answer, due to stupid limitations in the > language. Obviously the solution is to rewrite Format so that the box numbers are encoded as Church numerals. Then you can easily represent infinity: let zero = fun z s -> z;; let succ n = fun z s -> let s' = s () in s' (n z s);; (* unfortunately, eta-expansion needed because of value restriction *) let one = fun z s -> succ zero z s;; let two = fun z s -> succ one z s;; let three = fun z s -> succ two z s;; ... let rec infty = fun z s -> let s' = s () in s' (infty z s);; let eq m n = m (fun () let add m n = m n (fun () -> succ);; let print_num n = n () (fun () -> print_string "1"; fun _ -> ());; # print_num one;; 1- : unit = () # print_num (add two three);; 11111- : unit = () # print_num infty;; 111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111Interrupted. # print_num (succ infty);; 111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111Interrupted. P.S.: When I started writing this, I thought Pierre's post was in jest. Now I'm not so sure anymore...! -- Frank Atanassow, Information & Computing Sciences, Utrecht University Padualaan 14, PO Box 80.089, 3508 TB Utrecht, Netherlands Tel +31 (030) 253-3261 Fax +31 (030) 251-379 ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr