Guards -- not just for switch!

Tagir Valeev amaembo at gmail.com
Thu Nov 30 00:24:05 UTC 2017


    public Range(int lo, int hi)
        where (lo <= hi) {
            this.lo = lo;
            this.hi = hi;
    }

Probably it's too early to argue about syntax, but now it's too similar to
the 'while' loop. The 'where' keyword really looks like 'while' (same
length, prefix and suffix) and just like the 'while' loop it's followed by
parenthesized boolean expression and code block. I bet this would become a
source of confusion when reading the code. The 'requires' keyword, as Remi
suggests, sounds much better.

With best regards,
Tagir Valeev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20171130/d844c97f/attachment.html>


More information about the amber-spec-experts mailing list