elvis pattern refinement (was Syntax patterns)

Ruslan Shevchenko rssh at gradsoft.com.ua
Fri Apr 24 10:08:19 PDT 2009

> 2009/4/24 Ruslan Shevchenko <rssh at gradsoft.com.ua>:
>> But I mean this is incorrect, becouse it does not cover case of
>> 'null-safe method call' (which is often used for describing elvis).
> Officially, 'Elvis' just refers to the 'default if null' pattern. The
> other operators are the 'null-safe' operators.

In such case we need rename one. What I count was 'optimization of method
calls, via operators defined in elvis proposal', not occurences of elvis.

>> So, for example, in jetty we see only one matching for four patterns.
>> More - rereading ═proposal, I see that I implement check for 'safe
>> method
>> call' but in proposal we have 'safe index; safe field access, .. etc)
>> So, let's explicit define all aviable patterns.
>> First question: is 'safe-method call': i. e.
>> (a==null ? b : a.method(...)) pattern is correct ?
>> // Which can be rewritten as ═ ═a?.method() ?: b

> If I were writing Java today without the null-safe operators, then I
> would typically use an if-statement:
> if (foo != null) {
>   foo.process();
> }
> Bar bar = null;
> if (foo != null) {
>   bar = foo.process();
> }
> Stephen

 Great - you found hole, I just forgot, that IfStatement already can be
// will start write such pattern in Elvis1 now.

But let's return to original question:

is 'safe-method call': i. e. optimization of pattern
  (a==null ? b : a.method(...))
  // Which can be rewritten as
    a?.method() ?: b
  using operators, defined in elvis, can be counted as entry for
optimization as result of elvis proposal, or not ?


More information about the coin-dev mailing list