groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <glafo...@gmail.com>
Subject Re: [VOTE]About the Union Type for method/constructor declaration
Date Sun, 23 Jul 2017 15:21:24 GMT
Instead of going straight to a vote, let's discuss what we would like such
a feature to cover.
Then, once we reach a good level of consensus on what we want to achieve,
then we can launch a vote.

On my side, I'm very interested in this idea.
For example, Ceylon seemed to me to have a nice coverage of this aspect.
But I'd like this feature in Groovy to work also nicely with everything,
including our type inference (with static typing and static compilation).
And depending on what we want to do with a potential pattern matching
approach, it should also work with that.

Speaking of pattern matching, there's Brian Goetz' proposal here, for
pattern matching for Java:
http://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html
We should also avoid offering a different syntax as to what might come up
in the JDK later on, to avoid having two distinct syntaxes for the same
thing.
(although this proposal doesn't cover union types per se, it's something to
factor in, in our decisions)

Guillaume



On Sun, Jul 23, 2017 at 5:13 PM, Paolo Di Tommaso <paolo.ditommaso@gmail.com
> wrote:

> I agree with Paul.
>
> -1
>
>
> p
>
> On Sun, Jul 23, 2017 at 1:50 AM, Paul King <paulk@asert.com.au> 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-declar
>>> ation-tp5742265.html
>>> Sent from the Groovy Users mailing list archive at Nabble.com.
>>>
>>
>>
>


-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Mime
View raw message