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

[Caml-list] Does Caml have slow arithmetics ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2004-07-07 (15:49) From: Evgeny Chukreev Subject: Re: [Caml-list] Does Caml have slow arithmetics ?
```On Wed, 7 Jul 2004 16:58:03 +0200
Xavier Leroy <Xavier.Leroy@inria.fr> wrote:

> On the other hand, reducing inefficiencies already present in the
> source code isn't a priority.  In your "f" function, you asked for the
> construction of a pair, and you get that pair construction in
> ocamlopt's output.  If you didn't want the pair to be constructed, why
> did you write "f" this way?

This example was reduced version of:

let g a b =
a*b, a+b

let f a b =
let x, y = g a b in
...

with inlining we got:

let f a b =
let x, y = a*b, a+b in
...

so pair will be constructed...
There is no way to return >1 values at once without contstructing
memory block and then decomposing it. Yes, I could do this as in C:

let g a b r1 r2 =
r1 := a*b;
r2 := a+b

let f a b =
let x = ref 0 in
let y = ref 0 in
g a b x y;
...

but it's not best choice. Many of my functions return >1 values, so it's
not empty talking.

--
... WBR, Evgeny ...

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

```