[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | hubert.fauque@w... |
| Subject: | Re: Typing-problem |
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