[clean-list] Fastest shuffle with Clean?

F.S.A.Zuurbier@inter.nl.net F.S.A.Zuurbier@inter.nl.net
Fri, 14 Sep 2001 09:02:29 +0200 (MET DST)


Fabien wrote:
==========
> > >        #! rnd_elem = ar.[r] 
> > >        #! top_elem = ar.[top] 

[snip]

 the compiler is right, but I am baffled, I 
will have to review the language report. 
==========
An important thing here is the exclamation mark in =!
This enables the compiler to deduce that the array inspection in ar.[r] is performed 'immediately' (not lazily). Therefore the reference to ar has vanished before any array update takes place. This is a feature that was added to the uniqueness type system to make it more usable. That is, to make it possible to have some forms of syntactical reference duplication (in this case to ar), which are not really computational reference duplications.

Another example is in guards. You can have for instance four syntactical references to ar as in:

     | ..... ar ..... = ..... ar ..... 
     | ..... ar ..... = ..... ar ..... 
without the uniqueness type checker complaining. Computationally there is never more than one reference to ar at a time. Of course this makes assumptions about the evaluation order: it precludes speculative parallellism for instance.

Regards Erik Zuurbier