On Wed, Sep 28, 2011 at 5:30 PM, Damien Doligez wrote:
> You should say (Ftag (String.copy "Hello")) if you want a fresh mutable
> string. I wouldn't recommend appending "" or using Obj.dup (yuck!)
>
> I agree it was a mistake to make strings mutable, but we have to live
> with it for the time b
Dear Thomas,
Others have mostly answered your questions, but to be complete I want
to add the following:
> How come (Ftag "funny") is regarded as constant while
> (Rtag (ref "funny")) is not?
The difference here is that (ref "funny") is a function call. The
compiler doesn't know that the "ref"
> How come (Ftag "funny") is regarded as constant while
> (Rtag (ref "funny")) is not? After all, strings are mutable in OCaml,
> so there really is not that much of a conceptual difference between a
> string and a string ref in that respect:
This is just one of the axioms of the language. A sin
On Wed, Sep 28, 2011 at 1:53 PM, Thomas Fischbacher
wrote:
> How come (Ftag "funny") is regarded as constant while
> (Rtag (ref "funny")) is not? After all, strings are mutable in OCaml,
> so there really is not that much of a conceptual difference between a
> string and a string ref in that respe
Dear Damien,
if works
then (get_ftag "funny",get_rtag "funny")
else (Ftag "funny", Rtag (ref "funny"))
in
In this expression, you have four interesting subexpressions. Three of
them involve calling some function with "funny" as argument, and these
functions allocate values that point
Hi Thomas,
On 2011-09-27, at 19:30, Thomas Fischbacher wrote:
> For Rtag, inlining get_rtag does not make a difference, but for Ftag,
> inlining the get_ftag call breaks things both with the interpreter and
> compiler, but in different ways.
That's the key.
> if works
>then (get_ftag "funn
Dear Camels,
The example below shows GC behaviour which in my view is somewhat
weird: I am building two very similar sorts of hash tables that map
variant types to strings. The parameter "works" (which gets passed
through from the "demo" to the "setup" function) allows one to choose,
when callin