From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8SD82Pj009537 for ; Wed, 28 Sep 2011 15:08:02 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUDAOEag04SB0Qihmdsb2JhbABCDqd4FAEBAQoJCwcWJoFTAQEEAXkFCwsOOFcGiAuvHokBhwwEpFNT X-IronPort-AV: E=Sophos;i="4.68,455,1312149600"; d="scan'208";a="121974178" Received: from dmz-mailsec-scanner-5.mit.edu ([18.7.68.34]) by mail1-smtp-roc.national.inria.fr with ESMTP; 28 Sep 2011 15:07:56 +0200 X-AuditID: 12074422-b7ff56d00000092f-c5-4e831c2ba9fb Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 0F.74.02351.B2C138E4; Wed, 28 Sep 2011 09:07:55 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id p8SD7seQ017118; Wed, 28 Sep 2011 09:07:54 -0400 Received: from localhost (CONTENTS-VNDER-PRESSVRE.MIT.EDU [18.9.64.11]) (authenticated bits=0) (User authenticated as jfc@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p8SD7rjH023503; Wed, 28 Sep 2011 09:07:54 -0400 (EDT) Message-Id: <201109281307.p8SD7rjH023503@outgoing.mit.edu> To: Thomas Fischbacher cc: OCaML Mailing List In-reply-to: <4E830AC3.6020405@soton.ac.uk> References: <4E820844.7050705@soton.ac.uk> <2F6B5C48-88B0-4717-87FD-BD044B3D36E4@inria.fr> <4E830AC3.6020405@soton.ac.uk> Comments: In-reply-to Thomas Fischbacher message dated "Wed, 28 Sep 2011 12:53:39 +0100." X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.1.1 Date: Wed, 28 Sep 2011 09:07:53 -0400 From: John Carr X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsUixG6nrqst0+xn8Osol8WnHRtYLDa11Tgw eUx6cYjF49u3CywBTFFcNimpOZllqUX6dglcGRMb17EWvOGu+DqrsoFxEmcXIyeHhICJxKrn +5ggbDGJC/fWs3UxcnEICexjlLj44BIjhLOBUeLe9gdQTgOTxK3ueUAtHBy8AlYSi5ZHg3SL CBhJvG1czQxiMwtoS0z6+Z4FpEQYyF79LQEkzAlkXrtxiw0kLCRQKXH+oQ2IyQxk9r8qgzhB V+LjopnsIGEWAVWJrs1gs9kEZCUetXcxTmDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjX VC83s0QvNaV0EyM4eFyUdjD+PKh0iFGAg1GJh1eQsclPiDWxrLgy9xCjJAeTkijvKolmPyG+ pPyUyozE4oz4otKc1OJDjBIczEoivA2CQDnelMTKqtSifJiUNAeLkjgv104HPyGB9MSS1OzU 1ILUIpisDAeHkgSvqzRQo2BRanpqRVpmTglCmomDE2Q4D9BwdZAa3uKCxNzizHSI/ClGXY5v DzadYBRiycvPS5US593HD1QkAFKUUZoHNwcW9a8YxYHeEuYtABnFA0wYcJNeAS1hAlrytbAR ZElJIkJKqoFRsu7GLbtQKy5FnjWnVcVmKqfs/FR02Kv59qsK4RlysR9/Xgz7GPhq674ZH4OO MJi8TJs47cJnh6MSvaund13ZvmLzl+k73V21PwtkbFed1a2enp6axFAS+Nl2yiX2FkVffaG+ ssQH2evbPD89tWd7tttn1y2Wb7f6OsTTe/bdvXYsz7BZdvkrJZbijERDLeai4kQAW2OCHNUC AAA= Subject: Re: [Caml-list] Weird GC behaviour > 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 single string literal in OCaml source code yields the same value each time it is evaluated, even though arguably analgous constructs are handled differently: [1;2;3] == [1;2;3] may be true or false [|1;2|] == [|1;2|] will be false "const" == "const" will be false let f () = "const" in f () == f () will be true I would rather have identical string constants merged, as many C compilers do. (I am aware that it is possible to write programs with bugs.) The compiler could also treat string constants like array constants and generate a new value each time the expression is evaluated. In that case my last example would be false. If you want to argue analogies, consider let f () = F "hello" as an alias for something like let hello = [|'h';'e';'l';'l';'o'|] (* at top level *) let f () = F hello The name hello is as constant as any other top level binding. > But the problem I think I have with OCaml is: there just seems to be no > way to properly express the conceptual difference between '(1 2 3 4 5) > and (list 1 2 3 4 5): All I can say above is: Ftag "Hello". You can use Obj.dup to force a copy. I don't know whether there is a type safe interface.