Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 02FBF200CE5 for ; Sun, 23 Jul 2017 02:14:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF5201647F1; Sun, 23 Jul 2017 00:14:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1917E1647ED for ; Sun, 23 Jul 2017 02:14:14 +0200 (CEST) Received: (qmail 92797 invoked by uid 500); 23 Jul 2017 00:14:14 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 92787 invoked by uid 99); 23 Jul 2017 00:14:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jul 2017 00:14:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A2125C085C for ; Sun, 23 Jul 2017 00:14:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.313 X-Spam-Level: *** X-Spam-Status: No, score=3.313 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id SfG-txRFiSXv for ; Sun, 23 Jul 2017 00:14:03 +0000 (UTC) Received: from mx16lb.world4you.com (mx16lb.world4you.com [81.19.149.126]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id EA7A85F640 for ; Sun, 23 Jul 2017 00:14:02 +0000 (UTC) Received: from [84.112.214.51] (helo=[192.168.0.18]) by mx16lb.world4you.com with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.84_2) (envelope-from ) id 1dZ4Wy-000147-0B; Sun, 23 Jul 2017 02:13:56 +0200 Subject: Re: [VOTE]About the Union Type for method/constructor declaration To: users@groovy.apache.org, Paul King References: <1500762487438-5742265.post@n5.nabble.com> From: MG Message-ID: <1a853d3c-73c5-0a42-a480-645010981c87@arscreat.com> Date: Sun, 23 Jul 2017 02:13:52 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------1205975A4F9663ED1E0CC3A8" Content-Language: en-US X-SA-Do-Not-Run: Yes X-AV-Do-Run: Yes X-SA-Exim-Connect-IP: 84.112.214.51 X-SA-Exim-Mail-From: mgbiz@arscreat.com X-SA-Exim-Scanned: No (on mx16lb.world4you.com); SAEximRunCond expanded to false archived-at: Sun, 23 Jul 2017 00:14:16 -0000 This is a multi-part message in MIME format. --------------1205975A4F9663ED1E0CC3A8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Since this feature would have been helpful to me on several occasions (avoiding to have to introduce an interface or go dynamic) I would tentatively have said +1. Tentatively, because I am at the same time worried that a feature like that could prevent framework developers from introducing a meaningful interface hierarchy, over time possibly leading to code like void doGenericStuff(DeviceManager|VerySpecializedClassWithLongName|TautologicalFluxCompensatorMatrixElement|KungFooMaster x) { ... } On the other hand, IDE refactoring support could allow for automatic extraction of a shared functionality interface between the given classes here... I would also have thought of the exact same syntax - can you explain why you think it would break future extensions, Paul ? mg On 23.07.2017 01:50, Paul King wrote: > I would be leaning towards -1 without further justification. Even > though I don't think we want to rush into union types in Groovy, > wouldn't this syntax rule out us having it down the track? > > Cheers, Paul. > > > On Sun, Jul 23, 2017 at 8:28 AM, Daniel Sun > wrote: > > Hi all, > > I've been thinking about Union Type for method/constructor > declaration. It is similar to multi-catch in try-catch statement, e.g. > > class UnionTypeSample { > public UnionTypeSample(A|B|C p) { > // do something > } > > def m(D|E p) { > // do something > } > } > > Groovy will translate the above code into the following > code, which is > also the same way how multi-catch is handled. > > class UnionTypeSample { > public UnionTypeSample(A p) { > // do something > } > > public UnionTypeSample(B p) { > // do something > } > > public UnionTypeSample(C p) { > // do something > } > > def m(D p) { > // do something > } > > def m(E p) { > // do something > } > } > > Any thoughts? > ---------------------------------- > [+1] I like it > [ 0] Not bad > [-1] I do not like it > ---------------------------------- > > Cheers, > Daniel.Sun > > > > -- > View this message in context: > http://groovy.329449.n5.nabble.com/VOTE-About-the-Union-Type-for-method-constructor-declaration-tp5742265.html > > Sent from the Groovy Users mailing list archive at Nabble.com. > > --------------1205975A4F9663ED1E0CC3A8 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Since this feature would have been helpful to me on several occasions (avoiding to have to introduce an interface or go dynamic) I would tentatively have said +1.
Tentatively, because I am at the same time worried that a feature like that could prevent framework developers from introducing a meaningful interface hierarchy, over time possibly leading to code like
void doGenericStuff(DeviceManager|VerySpecializedClassWithLongName|TautologicalFluxCompensatorMatrixElement|KungFooMaster x) { ... }
On the other hand, IDE refactoring support could allow for automatic extraction of a shared functionality interface between the given classes here...

I would also have thought of the exact same syntax - can you explain why you think it would break future extensions, Paul ?
mg

On 23.07.2017 01:50, Paul King wrote:
I would be leaning towards -1 without further justification. Even though I don't think we want to rush into union types in Groovy, wouldn't this syntax rule out us having it down the track?

Cheers, Paul.


On Sun, Jul 23, 2017 at 8:28 AM, Daniel Sun <realbluesun@hotmail.com> wrote:
Hi all,

       I've been thinking about Union Type for method/constructor
declaration. It is similar to multi-catch in try-catch statement, e.g.

class UnionTypeSample {
  public UnionTypeSample(A|B|C p) {
     // do something
  }

  def m(D|E p) {
    // do something
  }
}

      Groovy will translate the above code into the following code, which is
also the same way how multi-catch is handled.

class UnionTypeSample {
  public UnionTypeSample(A p) {
     // do something
  }

  public UnionTypeSample(B p) {
     // do something
  }

  public UnionTypeSample(C p) {
     // do something
  }

  def m(D p) {
    // do something
  }

  def m(E p) {
    // do something
  }
}

     Any thoughts?
----------------------------------
  [+1] I like it
  [  0] Not bad
  [-1] I do not like it
----------------------------------

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/VOTE-About-the-Union-Type-for-method-constructor-declaration-tp5742265.html
Sent from the Groovy Users mailing list archive at Nabble.com.


--------------1205975A4F9663ED1E0CC3A8--