caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@best.com>
To: Tom _ <tom7ca@yahoo.com>
Cc: William Chesters <williamc@paneris.org>, caml-list@inria.fr
Subject: Re: [Caml-list] OCaml Speed for Block Convolutions
Date: Mon, 4 Jun 2001 19:52:55 -0700 (PDT)	[thread overview]
Message-ID: <Pine.BSF.4.21.0106041911310.5390-100000@shell5.ba.best.com> (raw)
In-Reply-To: <20010604221414.49620.qmail@web11906.mail.yahoo.com>

On Mon, 4 Jun 2001, Tom _ wrote:
> > E.g.
> > 
> >         let a = ref 0. in
> >         for i = 0 to n-1 do
> >           a := !a +. Array.unsafe_get xs i
> >         done
> 
> Incidentally, rather than trying to come up
> with other workaround for imperative variables,
> maybe it would be better to just make the
> straightforward functional implementation fast:
> 
>   let loop i total =
>     if i=n then total else
>     loop (i+1) (total + Array.unsafe_get xs i)
>   in loop 0 0.0
> 
> In fact, in a compiler that already has TRO
> and type inference, shouldn't this be entirely
> equivalent to an imperative loop?

Yes, but I think the general problem that William Chesters alludes to (the
overhead of polymorphic variables) is an interesting one to solve
regardless. Coming back to the subject of this thread, in an ideal world, 
there wouldn't be a need to distinguish between Bigarray and Array, you'd 
just use polymorphic arrays and the compiler would be smart enough to 
always get unboxed and tag free element representations. Supposedly Stalin 
comes close (I've only played with it on *very* small programs) so maybe 
one day we'll get something similar. And maybe David McClain wouldn't have
to write his inner loops in C or Fortran. What a wonderful world that
would be...

> Another approach would be to adopt a "functional"
> loop syntax as found in languages like SISAL.  

Or SAC. But OCaml arrays (and strings) aren't functional, and the only
Clean and efficient way I know to deal with that is uniqueness type
information. Functional arrays (trees or version arrays) are not efficient
enough to replace imperative arrays when you have single threaded usage; 
definitely not the right data structure for signal processing or numerical 
linear algebra. OTOH (changing the subject) it might be nice to have
built in version arrays and functional strings for other reasons.

-- Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-06-05  2:53 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-04 13:25 David McClain
2001-06-04 19:51 ` William Chesters
2001-06-04 20:05   ` Chris Hecker
2001-06-04 20:15   ` David McClain
2001-06-04 22:34     ` Markus Mottl
2001-06-06 20:13       ` William Chesters
2001-06-06 22:29         ` Chris Hecker
2001-06-07  7:42           ` William Chesters
2001-06-05  7:22     ` Chris Hecker
2001-06-06  6:27       ` David McClain
2001-06-04 22:14   ` Tom _
2001-06-04 22:57     ` Chris Hecker
2001-06-05  2:52     ` Brian Rogoff [this message]
2001-06-05 15:02       ` Stefan Monnier
2001-06-05 10:48   ` Tom _
2001-06-06  2:03     ` Hugo Herbelin
2001-06-06  4:04       ` Charles Martin
2001-06-06 18:25         ` William Chesters
2001-06-06 18:35       ` William Chesters
2001-06-06 18:40         ` Patrick M Doane
2001-06-07  1:50         ` Hugo Herbelin
2001-06-07 18:20         ` Tom _
2001-06-07 23:49           ` [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Jacques Garrigue
2001-06-08  0:20             ` [Caml-list] Currying in Ocaml Mark Wotton
2001-06-08 10:13               ` Anton Moscal
     [not found]             ` <Pine.LNX.4.21.0106081015000.1167-100000@hons.cs.usyd.edu.a u>
2001-06-08  0:38               ` Chris Hecker
2001-06-08  8:25             ` [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Ohad Rodeh
2001-06-08 15:21               ` Brian Rogoff
2001-06-08 17:30             ` Pierre Weis
2001-06-08 18:36               ` Stefan Monnier
2001-06-08 19:07                 ` Pierre Weis
2001-06-08 19:30               ` Michel Quercia
2001-06-11  6:42                 ` [Caml-list] should "a.(i)" be a reference? (was "let mutable") Judicaël Courant
2001-06-11 13:42                 ` [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Pierre Weis
2001-06-12  3:21                   ` Jacques Garrigue
2001-06-12  7:43                     ` Pierre Weis
2001-06-12  8:31                       ` Jacques Garrigue
2001-06-12 13:15                         ` Georges Brun-Cottan
2001-06-12 21:54                       ` John Max Skaller
2001-06-15  9:55               ` Michael Sperber [Mr. Preprocessor]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-01 18:38 [Caml-list] OCaml Speed for Block Convolutions David McClain
2001-06-01 22:51 ` Tom _
2001-06-02  0:10   ` Stefan Monnier
2001-06-04 10:12     ` Jacques Garrigue

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.BSF.4.21.0106041911310.5390-100000@shell5.ba.best.com \
    --to=bpr@best.com \
    --cc=caml-list@inria.fr \
    --cc=tom7ca@yahoo.com \
    --cc=williamc@paneris.org \
    /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).