English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
AW: [Caml-list] paralell assignment problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-08 (15:30)
From: skaller <skaller@u...>
Subject: Re: AW: [Caml-list] paralell assignment problem
On Wed, 2005-02-09 at 01:24, Beck01, Wolfgang wrote:

> > I seek a solution which minimises the number of assignments. 
> you probably know the 'xor trick' to swap value without a temporary:

I've heard of it :)

> Certainly not what you were looking for, but always nice :-)

You are right, it isn't useful here for three reasons:

(1) the values being assigned aren't necessarily bitwise
  copyable, in fact they're (more or less) arbitrary C++ values

(2) The intent is to reduce time not storage

(3) The RHS can be arbitrary expressions. To apply XOR,
we'd first assign each RHS expression to a temporary ..
and having done that we no longer need XOR, we can just
assign variables to those temporaries.

John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net