From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1C515BB81 for ; Mon, 28 Nov 2005 11:09:03 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jASA929m012270 for ; Mon, 28 Nov 2005 11:09:02 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA11761 for ; Mon, 28 Nov 2005 11:09:02 +0100 (MET) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jASA91J4012261 for ; Mon, 28 Nov 2005 11:09:02 +0100 Received: from [195.245.255.11] (port=62808 helo=bely) by mx1.mail.ru with asmtp id 1EgfwJ-000NAs-00 for caml-list@inria.fr; Mon, 28 Nov 2005 13:08:57 +0300 Received: from localhost (HELO BELY) [127.0.0.1] by bely (0.0.0.2) with ESMTP (Classic Hamster Vr. 2.0 Build 2.0.0.1) ; Mon, 28 Nov 2005 12:39:43 +0300 X-Comment-To: Thomas Fischbacher To: caml-list@inria.fr Subject: Re: [Caml-list] Bigarray question References: From: Dmitry Bely Date: Mon, 28 Nov 2005 12:39:43 +0300 In-Reply-To: (Thomas Fischbacher's message of "Sun, 27 Nov 2005 23:48:15 +0100 (CET)") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.5 (chayote, windows-nt) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Posting-Agent: Hamster/2.0.0.1 X-Miltered: at nez-perce with ID 438AD73E.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 438AD73D.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 bigarray:01 bigarray:01 pointer:01 pointer:01 externally:01 alloc:01 val:01 ocaml:01 writes:01 imho:01 dmitry:01 dmitry:01 explicitly:01 unsafe:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Thomas Fischbacher writes: >> > As far as I can see from the documentation, it is not explicitly permitted >> > to change a once allocated bigarray data structure in such a way that one >> > replaces the data pointer by some other data pointer (while retaining >> > size and type). This would, however, be quite useful in some situations. >> >> Is your bigarray a wrapper around some externally allocated data, created >> via alloc_bigarray() C call? > > It's a somewhat special case of just that situation, yes. > > I supposed I may just do so, however, the specification (documentation) > does not give me any guarantee that this is valid, so, at least the > documentation has to be changed before I can rely on this. 1. For the current implementation it's safe (use Data_bigarray_val(v) to change the data pointer). I don't see any reason why it could become unsafe. 2. It is up to you whether to use this feature or not. > There is a subtle difference between "just accidentally works" > and "works because it is guaranteed by specification". OCaml is a developing language, so IMHO nobody guarantees that nothing will change in the future. - Dmitry Bely