Pointers in Caml

Contact the author Pierre.Weis@inria.fr

Created the 10th of April 2000.

The corresponding Pascal type is closed to the définition C:

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

The cons function should also be explicitely 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: Thursday, April 13, 2000
Copyright © 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, INRIA all rights reserved.

Contact the author Pierre.Weis@inria.fr