Return-Path: X-Original-To: apmail-groovy-dev-archive@minotaur.apache.org Delivered-To: apmail-groovy-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1BAE117E90 for ; Tue, 16 Jun 2015 04:09:54 +0000 (UTC) Received: (qmail 41883 invoked by uid 500); 16 Jun 2015 04:09:54 -0000 Delivered-To: apmail-groovy-dev-archive@groovy.apache.org Received: (qmail 41836 invoked by uid 500); 16 Jun 2015 04:09:54 -0000 Mailing-List: contact dev-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.incubator.apache.org Delivered-To: mailing list dev@groovy.incubator.apache.org Received: (qmail 41824 invoked by uid 99); 16 Jun 2015 04:09:53 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2015 04:09:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 347E01A56A5 for ; Tue, 16 Jun 2015 04:09:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1 X-Spam-Level: * X-Spam-Status: No, score=1 tagged_above=-999 required=6.31 tests=[KAM_LIVE=1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id d8EJeLxU5TOf for ; Tue, 16 Jun 2015 04:09:44 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id CC36C42989 for ; Tue, 16 Jun 2015 04:09:43 +0000 (UTC) Received: from [192.168.1.3] ([85.180.101.117]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0Lp3sy-1ZYIFh0UTM-00euoM for ; Tue, 16 Jun 2015 06:09:37 +0200 Message-ID: <557FA289.8000500@gmx.org> Date: Tue, 16 Jun 2015 06:14:01 +0200 From: Jochen Theodorou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: dev@groovy.incubator.apache.org Subject: Re: intersect() returns duplicate elements References: <5577C0DB.2080207@gmx.org> <5577E3D9.7050807@gmx.org> <55799CD0.4000705@gmx.org> <557F2050.5000105@gmx.org> <557F50DA.9010107@asert.com.au> In-Reply-To: <557F50DA.9010107@asert.com.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:K+x3d2KkTh1Xr3Dwb04OaBwbE9qcQl8EiUv2DESeL8WHOtaHdyn fLXkl+UpL81JCEX4azh2wb+kgFUR53pdjqwGj8ZAKzmfJsrDU6x/z+E2Fx6ZvFS51Jtbg5a K+3Xhw1LXvEy4xdz/Yjcb0T69mu/PrkK80BsOXMjoO6tGfuFI71fWwgmei8SFjor3lV6Zm/ qZFzakx4Xhq04E72Ulckg== X-UI-Out-Filterresults: notjunk:1; Am 16.06.2015 00:25, schrieb Paul King: [...] > I don't necessarily think the existing name is necessarily that bad. > It follows the general definition of the word intersection as per > wikipedia - just not the more specialized set intersection defn. the trouble is that it confuses people... intersect can have a wide variety of meanings. For example if I intersect two circles I might get back a shape, that is no circle anymore. But most important here is of course the meaning of an intersection of two lists. And here the tendency to see the lists like sets is high imho. > Having said that, I'd have no problem with something that improves > things without creating further confusion. Are we looking for names > for the existing method or for a set-based one? findAll works for > me as a replacement/parallel name - we just don't want to create > confusion with the existing mutating retainAll. Also, something > like strictIntersect might work for a Set based variant. I was thinking of having Collection#findAll(Collection):Collection, which does what intersect does atm. Then deprecate intersect on everything but Set, plus a variant on SortedSet, which will check the comperators before delegating to the general variant, or do something special, since you can use the SortedSet for a faster algorithm. > There are many examples of Groovy methods which aren't commutative. > The fact we have left.operation(right) has an implication that > left and right might play different roles. We try to reduce the times > when lack of commutativity causes confusion and that most frequently > means methods which map to operators and names like intersect > would be a close second as to when confusion can arise but it doesn't > mean we have to always have commutativity. findAll(Collection) won't be commutative in general for example. sure. but I think we should try to avoid "mathematical terms" in such cases. bye blackdrag -- Jochen "blackdrag" Theodorou blog: http://blackdragsview.blogspot.com/