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
Big array with data managed by another value
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-11-14 (16:24)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] Big array with data managed by another value

Le 14 nov. 08 ŕ 16:58, Romain Beauxis a écrit :

> Yep, that's my current solution.

Another less friendly solution is to provide the bigarray in a  
callback and document the fact that the bigarray is only valid for the  
call and should not escape the scope.

val with_bigarray : custom -> (bigarray -> 'a) -> 'a

let with_bigarray c f =
   let ba = barray_of c in
   try let r = f ba in barray_invalidate ba; r with e ->  
barray_invalidate ba; raise e

barray_invalidate should set the bigarray size to 0 so that if the  
client doesn't respect the policy it will only get an out of bounds  
error (unless he compiled with -unsafe).