From: Frank Atanassow <franka@cs.uu.nl>
To: Pierre Weis <Pierre.Weis@inria.fr>
Cc: Hendrik Tews <tews@tcs.inf.tu-dresden.de>, caml-list@inria.fr
Subject: Re: [Caml-list] pretty printers and format and matrices
Date: Thu, 14 Jun 2001 23:35:27 +0200 [thread overview]
Message-ID: <20010614233527.A3906@cs.uu.nl> (raw)
In-Reply-To: <200106141937.VAA27299@pauillac.inria.fr>; from Pierre.Weis@inria.fr on Thu, Jun 14, 2001 at 09:37:44PM +0200
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
next prev parent reply other threads:[~2001-06-14 21:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-12 18:18 Chris Hecker
2001-06-12 19:03 ` Markus Mottl
2001-06-12 21:01 ` Chris Hecker
2001-06-13 12:16 ` Hendrik Tews
2001-06-14 19:37 ` Pierre Weis
2001-06-14 19:58 ` Patrick M Doane
2001-06-14 20:36 ` Pierre Weis
2001-06-14 21:35 ` Frank Atanassow [this message]
2001-06-15 12:43 ` Pierre Weis
2001-06-15 12:34 ` Hendrik Tews
2001-06-15 17:32 ` Pierre Weis
2001-06-14 6:46 ` Pierre Weis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010614233527.A3906@cs.uu.nl \
--to=franka@cs.uu.nl \
--cc=Pierre.Weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=tews@tcs.inf.tu-dresden.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox