Open jvasileff opened 8 years ago
@gavinking should the spec be adjusted instead? Although, if arguments are short circuited, it would seem results should be too, allowing opt?.plus(1).plus(1)
instead of opt?.plus(1)?.plus(1)
.
Hrm. That's a good one. The spec is written that way so that opt?.plus
is a valid function reference.
But I agree that we don't actually want to evaluate the arg
in opt?.plus(arg)
if opt
is null. Tricky.
With the program:
the nullsafe method operator acts to short-circuit argument evaluation, but my reading of Section 6.8.6 is that
opt1?.plus
should first be replaced with a null safe function, which is then (always) invoked with the argument++i
.When we force the issue with a
Callable
, the results are as expected: