[External] : Re: Guards

Gavin Bierman gavin.bierman at oracle.com
Wed Mar 10 09:46:41 UTC 2021

On 10 Mar 2021, at 00:55, Guy Steele <guy.steele at oracle.com<mailto:guy.steele at oracle.com>> wrote:

On Mar 9, 2021, at 1:47 PM, Brian Goetz <brian.goetz at oracle.com<mailto:brian.goetz at oracle.com>> wrote:

Apart from what have said about letting grobble to fully access to the bindings

Except that argument doesn't make sense.  Accessing the bindings is not a special behavior of grobble, but a natural consequence of flow scoping.  If I have P && g (or P & grobble(g)), then the scoping rules will tell us that the true set of P is present in g, and we're done.  Nothing special here.

Well, just to be fair, rules for flow scoping within expressions g && h already exist, but rules for P && g and P & Q do not yet exist.  It’s easy to see that they probably should exist, and that this can be done in a manner entirely analogous to the way flow scoping is already done in expressions, but it has been an implicit assumption in some of the past discussion that is worth making explicit.  “Consider it done!”  :-)

The draft JEP does try to be reasonably informative on this matter:

A conditional-and pattern p & q introduces the union of the pattern variables introduced by the patterns p and q. The scope of any pattern variable declaration in p includes the pattern q. (This allows for a pattern such as String s & true(s.length() > 1) -- a value matches this pattern if it can be cast to a String and that string has a length of two or more characters.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20210310/4dd5d0e7/attachment.htm>

More information about the amber-spec-experts mailing list