From dev-return-5351-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Sat Sep 8 14:54:52 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id D630C180621 for ; Sat, 8 Sep 2018 14:54:51 +0200 (CEST) Received: (qmail 24198 invoked by uid 500); 8 Sep 2018 12:54:50 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 24188 invoked by uid 99); 8 Sep 2018 12:54:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Sep 2018 12:54:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B6C63C035A for ; Sat, 8 Sep 2018 12:54:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id CJKafxMdqnEd for ; Sat, 8 Sep 2018 12:54:47 +0000 (UTC) Received: from smtpout10.partage.renater.fr (smtpout01-ext3.partage.renater.fr [194.254.240.34]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B155C5F385 for ; Sat, 8 Sep 2018 12:54:46 +0000 (UTC) Received: from zmtaout01.partage.renater.fr (zmtaout01.partage.renater.fr [194.254.240.30]) by smtpout10.partage.renater.fr (Postfix) with ESMTP id A6EEE61213 for ; Sat, 8 Sep 2018 14:54:38 +0200 (CEST) Received: from zmtaout01.partage.renater.fr (localhost [127.0.0.1]) by zmtaout01.partage.renater.fr (Postfix) with ESMTPS id 2E4BD1A004D for ; Sat, 8 Sep 2018 14:54:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zmtaout01.partage.renater.fr (Postfix) with ESMTP id 1F18B1A010B for ; Sat, 8 Sep 2018 14:54:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at zmtaout01.partage.renater.fr Received: from zmtaout01.partage.renater.fr ([127.0.0.1]) by localhost (zmtaout01.partage.renater.fr [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TtJCwigoxsBy for ; Sat, 8 Sep 2018 14:54:38 +0200 (CEST) Received: from zstore-b1-015.partage.renater.fr (zstore-b1-015.partage.renater.fr [10.254.241.127]) by zmtaout01.partage.renater.fr (Postfix) with ESMTP id 066051A004D for ; Sat, 8 Sep 2018 14:54:38 +0200 (CEST) Date: Sat, 8 Sep 2018 14:54:38 +0200 (CEST) From: Remi Forax To: dev Message-ID: <1475475699.1819303.1536411278202.JavaMail.zimbra@u-pem.fr> In-Reply-To: References: Subject: Re: About type inference of method return value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [88.187.40.25] X-Mailer: Zimbra 8.8.8_GA_3008 (ZimbraWebClient - FF61 (Linux)/8.8.8_GA_1703) Thread-Topic: About type inference of method return value Thread-Index: 7w8akJONcwy8PGe4WjNIyGepYyf4VQ== ----- Mail original ----- > De: "Jochen Theodorou" > =C3=80: "dev" > Envoy=C3=A9: Samedi 8 Septembre 2018 14:22:25 > Objet: Re: About type inference of method return value [...] >=20 > "var" is a bit a different story. It will lead to surprising types being > used and partially violates the paradigm that you should not use the > most special class for your variables if not needed. But even then the > effect is quite local. If you keep your methods small, as you should > anyway, then there is not much of a disadvantage here to be seen in my > opinion. But it already makes the program less readable for another > user. It is the same in dynamic Groovy with def... Which shows you > simply have to learn to read the method differently. But the effect is > very localized. yes, using an interface instead of a concrete type is only useful if the ty= pe is visible from the outside, so parameter types/return type of public me= thods or public fields should use interfaces. A local variable (or a privat= e field) is never visible from another class so one should use a concrete t= ype here, there is not point to ask the VM to de-virtualize when it's not n= ecessary (even if de-virtualisation is cheap). =20 >=20 > Now return type inference is not, as I have shown already. And that, > plus the lazy developer part, is why I am not friend of this. >=20 > bye Jochen R=C3=A9mi