Union types (Sum types, really) shine when used with pattern matching and 
exhaustion check. 
This is not provided by this proposal. 
Without that, there are already a number of ways to encode them in Groovy. 

-1
Dierk

sent from:mobile 

> Am 23.07.2017 um 02:13 schrieb MG <mg...@arscreat.com>:
> 
> 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 <realblue...@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.
>> 
> 

Reply via email to