caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <brian.hurt@qlogic.com>
To: Ville-Pertti Keinonen <will@exomi.com>
Cc: Gregory Morrisett <jgm@CS.Cornell.EDU>, <caml-list@inria.fr>
Subject: Re: [Caml-list] Bug?  Printf, %X and negative numbers
Date: Fri, 4 Apr 2003 10:14:55 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.33.0304040959570.2225-100000@eagle.ancor.com> (raw)
In-Reply-To: <C15E9724-654F-11D7-B5BF-000393863F70@exomi.com>


Sorry for being quiet for a couple of days- came down with the flu.  I'm 
catching up on my email, so pardon the jumping into the middle of 
discussions.

On Thu, 3 Apr 2003, Ville-Pertti Keinonen wrote:
> 
> This is what I was suggesting.  With its whole-program analysis, this 
> is obviously more straightforward for MLton, but I think it's also 
> feasible for more practical compilers (without ending up with C++-like 
> compile times).
> 

I hadn't thought about polymorphism when I made my example.  And thinking 
about it, while it still might be doable, it becomes way more ugly.

One of the things I dislike about C++ template is code bloat.  This is the 
undiscussed cost of templates.  So you make a template foo<type>.  You 
create a foo<int> and the compiler has to spit out a specialized instance 
of foo to deal with ints.  Do foo<long> and now you have two foos.  Then 
you do foo<char>, foo<short>, foo<float>, foo<double>, foo<struct this>, 
foo<struct that>, etc.  And this is assuming that the compiler is smart 
enough to notice that foo<unsigned long> and foo<size_t> can generally use 
the same specialization.  And it takes heroic efforts to figure out that 
foo<int> and foo<unsigned int> might be able to use the same 
specialization.  Maybe.

So now you a dozen different specializations of foo<>.  All almost 
identical.  Say bye bye to any code locality.  And this isn't even 
mentioning badly designed templates, like the one I found (no kidding!) 
for an array template that took it's length as a parameter.  The compiler 
had to produce different specializations of the code for arrays length 3 
and arrays length 4.  Or some early C++ compilers which didn't have a way 
to say "this specialization is produced somewhere else", so if you used 
foo<int> in 100 different files, you got 100 copies of the specialization 
of foo onto ints.

This experience has made me violently opposed to specialization of code if 
it can be at all avoided.  I'll take the performance hit to avoid having 
uppity zillion almost-identical copies of my code kicking around.\

And this applies to Ocaml even more so.  I mean, consider the function:

let f x = ...

OK, so to specialize it for unboxed ints vr.s pointers takes two 
implementations of the function, f_pointer and f_int, right?  So now 
consider the function:

let f x y z w = ...

Do we need 16 different specializations for this function?  

No.  I'll take 31-bit ints any day.

Brian


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


  parent reply	other threads:[~2003-04-04 16:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-02 18:42 Gregory Morrisett
2003-04-02 21:12 ` Ville-Pertti Keinonen
2003-04-02 21:46   ` Lauri Alanko
2003-04-03 17:40     ` Ville-Pertti Keinonen
2003-04-04 16:14   ` Brian Hurt [this message]
2003-04-04 17:14     ` Ville-Pertti Keinonen
2003-04-04 17:27     ` Falk Hueffner
2003-04-03  0:52 ` brogoff
  -- strict thread matches above, loose matches on Subject: below --
2003-04-03  9:29 Fabrice Le Fessant
2003-03-28 21:19 Brian Hurt
2003-03-28 22:21 ` Yutaka OIWA
2003-03-30  9:51 ` Xavier Leroy
2003-03-31 15:44   ` Brian Hurt
2003-03-31 17:13     ` Ville-Pertti Keinonen
2003-04-01  8:19     ` Xavier Leroy
2003-04-01 16:09       ` David Brown
2003-04-01 16:45       ` Tim Freeman
2003-04-01 18:59         ` Brian Hurt
2003-04-01 19:16           ` Ville-Pertti Keinonen
2003-04-01 19:23             ` Tim Freeman
2003-04-01 21:00               ` Ville-Pertti Keinonen
2003-04-01 19:56             ` Brian Hurt
2003-04-01 20:45               ` Ville-Pertti Keinonen
2003-04-01 21:03                 ` Brian Hurt
2003-04-02  8:55             ` Andreas Rossberg
2003-04-02  9:20               ` Ville-Pertti Keinonen
2003-04-01 18:34       ` Ville-Pertti Keinonen
2003-04-02 11:44 ` Claude Marche

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=Pine.LNX.4.33.0304040959570.2225-100000@eagle.ancor.com \
    --to=brian.hurt@qlogic.com \
    --cc=caml-list@inria.fr \
    --cc=jgm@CS.Cornell.EDU \
    --cc=will@exomi.com \
    /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;
as well as URLs for NNTP newsgroup(s).