Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
partial evaluation anyone?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thorsten Ohl <ohl@c...>
Subject: partial evaluation anyone?
[ Sorry, no french version .... ]

Continuing the thread on optimizations for numerical code:

Is it possible to find out (at run-time) whether some components of a
function's return value are discarded by the caller?

Example (pseudo code, in real life this is an interface to LAPACK):

  let diagonalize matrix =
    (* Compute real and imaginary parts of the eigenvalues and
       the left and right eigenvectors of MATRIX.  *)

Sometimes, one wants the eigenvalues only

  let (wr,wi,_,_) = diagonalize some_really_big_matrix

but since diagonalize doesn't know that the eigenvectors will be
thrown away, it will calculate them anyway, which can be substantial
overhead for large matrices.

One way out would be to clutter the namespace with many different
functions, one for each (likely) combination of return values, or to
pass this information as a seperate argument (like LAPACK does in

IMHO, both approaches are ugly kludges and it would be much nicer, if
a function could find out which parts of its return value are being
thrown away instantly.  (Note that I'm not asking for a complete
dependency analysis.  One level of function invocation would be
sufficient to allow the programmers to give the proper hints.)

Is there a trick to do this now?  Or is there a chance to get the
implementors interestet?


Thorsten Ohl, Physics Department, TH Darmstadt --- PGP: AF 38 FF CE 03 8A 2E A7 -------- 8F 2A C1 86 8C 06 32 6B