<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On Apr 4, 2024, at 9:30 AM, forax@univ-mlv.fr wrote:</div>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">
<div>
<div>
<div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;">
<div data-marker="__QUOTED_TEXT__">
<div>Patterns are not dual of methods, pattern deconstructors are dual of methods, but this is a special case.<br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div>A pattern not only have a sequence of match results, it can have parameters too.<br data-mce-bogus="1">
</div>
<div>For example, I may want to introduce an instance pattern asInteger() in java.lang.String that works like Integer.parseInt() but not match instead of throwing an exception if the string does not represent an integer. I may also want that pattern to decode
hexadecimal so like Integer.parsing(int radix), I want my pattern to also takes a radix as parameter. In that case, my pattern asInteger() has an int value as match result and has an int radix as parameter.</div>
<div><br data-mce-bogus="1">
</div>
<div>Using the carrier syntax, it's something like<br data-mce-bogus="1">
</div>
<div> carrier(int value) asInteger(int radix) { ... }<br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div>or without the carrier syntax but with a keyword pattern, it's something like<br data-mce-bogus="1">
</div>
<div> pattern (int value) asInteger(int radix) { … }</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</div>
<div>I think what is missing is a necessary shift in terminology under Brian’s new proposal: if parameters are needed for a pattern, then in effect you curry it. In this new model, `asInteger` is not a pattern; rather, it is a pattern factory—that is, a method
that returns a pattern. This is possible because of the introduction of SAPs, so that a pattern can be expressed using lambda syntax.</div>
<div><br>
</div>
<div>So we should speak of method `asInteger` as a pattern factory, and `asInteger(16)` as a pattern.</div>
<div><br>
</div>
<div>—Guy</div>
<div><br>
</div>
</body>
</html>