Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-06-01 (15:17)
From: hubert.fauque@w...
Subject: Re: Typing-problem
aXl <> writes:

> Hi, 
> why is in the following example b of type "string -> string" ?

because a is of type string->string and b=a

> 	let a = id id;;
> 	let b = a;;
> 	a "foo";; 
> 	(* until here it's covered by the faq's *)
> 	b;;

let b = a   defines a new name (b) for the object designed by a;
it doesn't construct a new object, and it doesn't do a new call (id id);

it is different from
let a = id id;;
let b = id id;;

The Caml let ..= ..  is different from the assignment in C or Pascal;
in C if you write
there is a variable "a" which already as a place
in memory, and a=b means: copy the memory location of b to a;

in Caml let defines a new name; it's the right of the = which may
construct a new object; that's why 
let a = id id
let b = a

is different from 
lat a = id id
let b = id id