Pointers in Caml

Contact the author Pierre.Weis@inria.fr

Created the 10th of April 2000.

The corresponding Pascal type is closed to the C definition:

type
 list = ^cell;
 cell = record
  hd: integer;
  tl: list;
 end;

The cons function should also be explicitly defined, and uses fields assignment to initialize the data.

{Creating a list cell}
function cons (x: integer; l: list): list;
 var p: list;
 begin
  new(p);
  p^.hd := x;
  p^.tl := l;
  cons := p
 end;


Caml home page Last modified: Friday, March 26, 2004
Copyright © 1995 - 2004, INRIA all rights reserved.

Contact the author Pierre.Weis@inria.fr