Re: Typing-problem

Date: Mon May 31 1999 - 14:42:20 MET DST

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 <> 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


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