Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Some suggested improvements to the Graphics and Bigarray modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Some suggested improvements to the Graphics and Bigarray modules
Hi,

On Sun, Oct 14, 2001 at 01:16:25AM +0200, Berke Durak wrote:

> Erm, I couldn't use both Bigarrays and Streams under 3.03 ALPHA. Tried
> '-pp camlp4o'. Grepped 'bigarray' in ocaml-3.03-alpha/camlp4,
> unsuccessfully. Am I missing something ?

Sorry, I meant it is fixed in the CVS version. Here is the patch:



Index: camlp4/etc/pa_o.ml
===================================================================
diff -c -r1.12 -r1.13
*** camlp4/etc/pa_o.ml	2001/10/09 16:39:04	1.12
--- camlp4/etc/pa_o.ml	2001/10/12 15:35:41	1.13
***************
*** 10,16 ****
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: pa_o.ml,v 1.12 2001/10/09 16:39:04 ddr Exp $ *)
  
  open Stdpp;
  open Pcaml;
--- 10,16 ----
  (*                                                                     *)
  (***********************************************************************)
  
! (* $Id: pa_o.ml,v 1.13 2001/10/12 15:35:41 ddr Exp $ *)
  
  open Stdpp;
  open Pcaml;
***************
*** 292,297 ****
--- 292,323 ----
    | _ -> None ]
  ;
  
+ value bigarray_get loc arr arg =
+   let coords =
+     match arg with
+     [ <:expr< ($list:el$) >> -> el
+     | _ -> [arg] ]
+   in
+   match coords with
+   [ [c1] -> <:expr< Bigarray.Array1.get $arr$ $c1$ >>
+   | [c1; c2] -> <:expr< Bigarray.Array2.get $arr$ $c1$ $c2$ >>
+   | [c1; c2; c3] -> <:expr< Bigarray.Array3.get $arr$ $c1$ $c2$ $c3$ >>
+   | coords -> <:expr< Bigarray.Genarray.get $arr$ [| $list:coords$ |] >> ]
+ ;
+ 
+ value bigarray_set loc var newval =
+   match var with
+   [ <:expr< Bigarray.Array1.get $arr$ $c1$ >> ->
+       Some <:expr< Bigarray.Array1.set $arr$ $c1$ $newval$ >>
+   | <:expr< Bigarray.Array2.get $arr$ $c1$ $c2$ >> ->
+       Some <:expr< Bigarray.Array2.set $arr$ $c1$ $c2$ $newval$ >>
+   | <:expr< Bigarray.Array3.get $arr$ $c1$ $c2$ $c3$ >> ->
+       Some <:expr< Bigarray.Array3.set $arr$ $c1$ $c2$ $c3$ $newval$ >>
+   | <:expr< Bigarray.Genarray.get $arr$ [| $list:coords$ |] >> ->
+       Some <:expr< Bigarray.Genarray.set $arr$ [| $list:coords$ |] $newval$ >>
+   | _ -> None ]
+ ;
+ 
  (* ...works bad...
  value rec sync cs =
    match cs with parser
***************
*** 498,504 ****
      | ":=" NONA
        [ e1 = SELF; ":="; e2 = expr LEVEL "expr1" ->
            <:expr< $e1$.val := $e2$ >>
!       | e1 = SELF; "<-"; e2 = expr LEVEL "expr1" -> <:expr< $e1$ := $e2$ >> ]
      | "||" RIGHTA
        [ e1 = SELF; "or"; e2 = SELF -> <:expr< $lid:"or"$ $e1$ $e2$ >>
        | e1 = SELF; "||"; e2 = SELF -> <:expr< $e1$ || $e2$ >> ]
--- 524,533 ----
      | ":=" NONA
        [ e1 = SELF; ":="; e2 = expr LEVEL "expr1" ->
            <:expr< $e1$.val := $e2$ >>
!       | e1 = SELF; "<-"; e2 = expr LEVEL "expr1" ->
!           match bigarray_set loc e1 e2 with
!           [ Some e -> e
!           | None -> <:expr< $e1$ := $e2$ >> ] ]
      | "||" RIGHTA
        [ e1 = SELF; "or"; e2 = SELF -> <:expr< $lid:"or"$ $e1$ $e2$ >>
        | e1 = SELF; "||"; e2 = SELF -> <:expr< $e1$ || $e2$ >> ]
***************
*** 570,575 ****
--- 599,605 ----
      | "simple" LEFTA
        [ e1 = SELF; "."; "("; e2 = SELF; ")" -> <:expr< $e1$ .( $e2$ ) >>
        | e1 = SELF; "."; "["; e2 = SELF; "]" -> <:expr< $e1$ .[ $e2$ ] >>
+       | e1 = SELF; "."; "{"; e2 = SELF; "}" -> bigarray_get loc e1 e2
        | e1 = SELF; "."; e2 = SELF -> <:expr< $e1$ . $e2$ >>
        | "!"; e = SELF -> <:expr< $e$ . val>>
        | f = [ op = "~-" -> op | op = "~-." -> op | op = prefixop -> op ];

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr