<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<br>
<blockquote type="cite"
cite="mid:1162477749.995924.1599515765693.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">
<div><br data-mce-bogus="1">
</div>
<div>The deconstruction pattern is a special case of type
pattern</div>
</div>
</div>
</blockquote>
<br>
No, it isn't. I think you want it to be, but it isn't. <br>
<br>
<blockquote type="cite"
cite="mid:1162477749.995924.1599515765693.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">
<div>, both starts by doing a typecheck (an instanceof), what
is different is how they bind variables after the typecheck.<br>
</div>
<div>So having the type inference on the type used by the
typecheck working for the type pattern but not for the
destruction pattern strike me as weird.<br
data-mce-bogus="1">
</div>
</div>
</div>
</blockquote>
<br>
I think you may just not understand the model here. <br>
<br>
In generality, a pattern:<br>
<br>
 - Is either total or partial. Deconstruction patterns are total;
other patterns we'll be able to express later, such as
`Optional.of(var x)`, are partial.<br>
 - Has a target type. In order for the pattern to match, the
dynamic type of the target must be cast-convertible to this target
type.<br>
 - Has a set of output bindings. <br>
<br>
So, if the user says:<br>
<br>
   case Foo(int x):<br>
<br>
This means:<br>
 - (static) perform overload selection on the deconstructors of Foo,
and look for one that is compatible with the binding list `(int
x)`. Compile error if there isn't one (or are too many.)<br>
 - (dynamic) test the target to see if it is cast-convertible to
Foo. If it is, because the pattern is total (no additional match
conditions), the deconstruction pattern is going to match. Invoke
the deconstructor to get the bindings.<br>
<br>
<blockquote type="cite"
cite="mid:1162477749.995924.1599515765693.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">
<div>At the same time, i understand why people can find the
syntax awkward. I just want to be sure that it's not awkward
just because it's a new syntax.</div>
</div>
</div>
</blockquote>
<br>
It's not the syntax, it's the concept. <br>
<br>
<blockquote type="cite"
cite="mid:1162477749.995924.1599515765693.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">
<div>By example, with this switch, that has two cases that are
semantically identical<br data-mce-bogus="1">
</div>
<div>Â switch(point) {</div>
<div>Â Â Â case Point p where p.x() == 0 -> ...<br
data-mce-bogus="1">
</div>
<div>Â Â case Point(var x, var _) where x == 0 -> ...<br
data-mce-bogus="1">
</div>
</div>
</div>
</blockquote>
<br>
No, they are not semantically identical, except maybe for a record
(because records are so constrained.)Â The first is invoking a
method p.x(); the second is invoking a deconstructor, which has a
binding called x. If the two happen to be talking about the same x,
then it will come out the same, but you have no reason to assume
that just based on the spelling of `x`. They could be describing
entirely different things. The language has no business guessing
the semantics of a method based on its name. <br>
<br>
In order to make them work out, you need a system of "properties" to
guarantee that when a deconstructor binds a `x`, and an accessor
method returns an `x`, they are guaranteed to be the same `x`. I
don't blame you for wanting such a system, but you don't get to
sneak it in the back door....<br>
<br>
<blockquote type="cite"
cite="mid:1162477749.995924.1599515765693.JavaMail.zimbra@u-pem.fr">
<div style="font-family: arial, helvetica, sans-serif; font-size:
12pt; color: #000000">
<div data-marker="__QUOTED_TEXT__">How the deconstructors are
represented in the surface language, how they are called or
how the data values flow to the bindings are another stories
for another time.<br>
</div>
</div>
</blockquote>
<br>
No, this is not a syntax problem; it is a conceptual problem. You
are asserting that deconstructors means something different than
they do. <br>
<br>
</body>
</html>