caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Understanding Format
@ 2012-07-23  9:05 Alain Frisch
  2012-07-24 13:16 ` Olivier Andrieu
  0 siblings, 1 reply; 2+ messages in thread
From: Alain Frisch @ 2012-07-23  9:05 UTC (permalink / raw)
  To: caml-list

Hi all,

I'm trying to understand the semantics of Format boxes, and I need some 
help!  Consider the following:

let () =
   set_margin 500;
   open_vbox 0;
   for _i = 1 to 300 do
     open_hbox ();
     print_string "x";
     close_box ()
   done;
   close_box ()


Format inserts line breaks, even though the page width (margin) should 
be large enough to contain 300 characters (and there is no break hint 
anyway). Why does it do it?   Changing the value passed to set_margin 
does not seem to make a difference (except for small values < 70).

I'm also interest in understanding the performance of Format. In the 
example above, changing 300 to 1000000, the program takes about 0.6s to 
execute on my machine.  This does not seem to be impacted by the value 
passed to set_margin... except for large values (like max_int), where 
the program takes about 1s.  Is this slowdown for "unbounded" width 
expected?  (Interestingly, despite this slowdown, the unbounded-width 
version allocates less than the bounded-width case.)


Alain

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

end of thread, other threads:[~2012-07-24 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-23  9:05 [Caml-list] Understanding Format Alain Frisch
2012-07-24 13:16 ` Olivier Andrieu

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