Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Immutable Datastructures with good Sharing Date: Sun, 06 Nov 2011 14:16:22 +0100 Organization: albasani.net Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net GfRXXsIzSjnfcq1MYzp/XwXvtI1GM3uSUUI2rOYfl8ZGA8Cy484e8SZmNvSjxT336P+d2PTDoZx7JEbBoNXb8A== NNTP-Posting-Date: Sun, 6 Nov 2011 13:16:22 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="ki6dNOobJPM5evgPBV+vt1yi2Y20glx+7VkOHb0T0fnYI9SGTIOC61mIuhuwT3b/yUvBgoTdhgEiy1kv1LMMe6lRrHY6R9jWpMeYC8ufbdn/HVuvR+ARs049Tw276EBq"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 In-Reply-To: Cancel-Lock: sha1:pCiK97vU3wV1udkou17u3dGBmBk= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9649 Arved Sandstrom schrieb: > "We have just shown that lazy evaluation is necessary to implement > amortized data structures purely functionally." I you strike out the phrase "purely functionally", then I read it as "sufficient". I can imagine that a little destructive mechanism under the hood of a datastructure, does not need to violate it beeing immutable. Here is an example, take the hashCode() function java.lang.String. Usually the value is cached, so code reads: if (hash==0) { /* compute the hash in h */ hash = h; } return hash; This does not destroy immutability of the String. So I would be interested in Java solutions for the problem at hand. And this solution could be inspired by solutions coming from the purely functional world, but they don't need to be based on purely functional programming. The only requirement is "immutable" and "good sharing". Bye