ValueType.findConstructor

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 26 21:28:19 UTC 2017


> On 26 Jun 2017, at 12:08, John Rose <john.r.rose at oracle.com> wrote:
> 
> On Jun 26, 2017, at 11:43 AM, Paul Sandoz <paul.sandoz at oracle.com <mailto:paul.sandoz at oracle.com>> wrote:
>> 
>>   Point p = ...
>>   if (p match Point(x, _, z))
>>     return new Point(z, another_y , x)
>>   else
>>     throw new Error()
> 
> If you mean to swap z and x in the reconstruction,
> it's a good example of an ad hoc reconstruction which
> is more than just a "wither”.

Yes, i was combining some argument shuffling and replacement, perhaps the example should of been:

   Point p = ...
   if (p match Point(x, _, _))
     return new Point(x, another_y , another_z)
   else
     throw new Error()

Paul.

> 
> This makes me think there should be a warning
> issued by the compiler if you choose a name for
> a component of a match result which conflicts
> with the name advertised by the constructor.
> So "p match Point(z, y, x)" would get a warning
> on the first and third arguments, if the constructor
> were "Point(x, y, z)" and Point actually had those
> names as part of its API.
> 



More information about the valhalla-dev mailing list