Chapter 8  Language extensions

This chapter describes language extensions and convenience features that are implemented in OCaml, but not described in the OCaml reference manual.

11  Syntax for Bigarray access

(Introduced in Objective Caml 3.00)

expr::= ...  
  expr .{  expr  { , expr } }  
  expr .{  expr  { , expr } } <-  expr

This extension provides syntactic sugar for getting and setting elements in the arrays provided by the Bigarray module.

The short expressions are translated into calls to functions of the Bigarray module as described in the following table.

expressiontranslation
expr0.{ expr1}Bigarray.Array1.get expr0  expr1
expr0.{ expr1} <- exprBigarray.Array1.set expr0  expr1  expr
expr0.{ expr1,  expr2}Bigarray.Array2.get expr0  expr1  expr2
expr0.{ expr1,  expr2} <- exprBigarray.Array2.set expr0  expr1  expr2  expr
expr0.{ expr1,  expr2,  expr3}Bigarray.Array3.get expr0  expr1  expr2  expr3
expr0.{ expr1,  expr2,  expr3} <- exprBigarray.Array3.set expr0  expr1  expr2  expr3  expr
expr0.{ expr1,,  exprn}Bigarray.Genarray.get expr0 [|  expr1,,  exprn |]
expr0.{ expr1,,  exprn} <- exprBigarray.Genarray.set expr0 [|  expr1,,  exprn |]  expr

The last two entries are valid for any n > 3.