Re: Typing-problem

From: hubert.fauque@wanadoo.fr
Date: Mon May 31 1999 - 14:42:20 MET DST


From: hubert.fauque@wanadoo.fr
To: caml-list@inria.fr
Subject: Re: Typing-problem
In-Reply-To: aXl's message of "Sun, 30 May 1999 17:24:50 +0200 (MET DST)"
Date: 31 May 1999 14:42:20 +0200

aXl <krauth@fmi.uni-passau.de> 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
        a=b;
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

Hubert
hubert.fauque@inria.fr



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:22 MET