Geoffrey Irving wrote:
> Most imperative operations in numerical code (my own, at least)
> involve incremental construction of vectors, sometimes in random
> access order.  In many cases these arrays aren't modified once they
> are created.  Currently each location in BitC memory is either
> permanently mutable or permanently immutable, which means that an
> array constructed using imperative operations must be copied in order
> to become immutable.  How difficult would it be to relax this
> restriction enough to allow the following pattern:
> 
>     f : vector int -> ()
>     freeze : mutable 'a -> 'a # with escape restrictions
>     let a = make-vector 100 0
>     for i in range(100):
>         a[i] = i
>     f (freeze a)
> 
> where the "freeze" function doesn't copy any data, just unsets the
> mutability flag and returns its argument.  I.e.,

You could always compose lifted computations. So arithmetic would
operate on and produce lifted expressions instead of actual values.

When a value is actually needed, a single mutable array could be
provided for the actual computation to use.

I don't think BitC requires any extensions for this approach.

Sandro

_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to